We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Image Resize

Where does phalcon gd apater store image file before save() function call??? I have to upload resized image file to Amazon Aws which needs resized image path



6.0k
Accepted
answer

Hi, to generate a resized image try this code:


<?php
if($upload->moveTo($path))
         {
                   $name_of_miniature = "example_name123";
                   $img = new Phalcon\Image\Adapter\Gd($path); 
                   $path_mini = "img/miniatures/".$name_of_miniature.".jpg"; 
                    //117 px width, 90 px height
                    $img->resize(117,90)->crop(117,90);
                    if($img->save($path_mini, 100))
                    {
                      //  ok
                    }
                    else
                    {
                      // bad
                    }
         }

Thanks PolDeveloper I have resized image and store that image to temp directory of my linux machine and upload to Amazon from that path

Hi, to generate a resized image try this code:


<?php
if($upload->moveTo($path))
       {
                 $name_of_miniature = "example_name123";
                 $img = new Phalcon\Image\Adapter\Gd($path); 
                 $path_mini = "img/miniatures/".$name_of_miniature.".jpg"; 
                  //117 px width, 90 px height
                  $img->resize(117,90)->crop(117,90);
                  if($img->save($path_mini, 100))
                  {
                    //  ok
                  }
                  else
                  {
                    // bad
                  }
       }

Very Good. Cheers!