![]() |
Image Manipulation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Image Manipulation (/showthread.php?tid=76102) |
Image Manipulation - Marcolino92 - 04-14-2020 I can't understand what the syntax for image manipulation is. I have this in my controller, which moves the renamed image to the folder and saves its name in the database. However, I would like to manage the resize, but I cannot understand where to act. This is my controller: PHP Code: $data['validation']->setRules([ Where should I enter this? PHP Code: $image = \Config\Services::image() I don't need you to upload two photos (original and miniature), but only the reduced image. RE: Image Manipulation - Leo - 04-14-2020 I did this 2 days ago! Or yesterday maybe... basically, you don't need this (unless you want to run more security checks on the file before moving itto desired folder? or keep the original?): $img->move(WRITEPATH.'uploads/photos', $newName); just fiddle with the temporary upload path if($img->isValid() && ! $img->hasMoved()){ $newName = $img->getRandomName(); //$img->move(WRITEPATH.'uploads/photos', $newName); <--- not needed $source = $img->getTempName(); $image = \Config\Services::image() ->withFile($source) ->fit(100, 100, 'center') ->save($targetDirectory.'/'.$newName); } RE: Image Manipulation - Marcolino92 - 04-14-2020 Great, thank you very much. |