CodeIgniter Forums
Use of Image Manipulation class in news app - 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: Use of Image Manipulation class in news app (/showthread.php?tid=76016)



Use of Image Manipulation class in news app - gesdinet - 04-07-2020

In this demo: https://codeigniter.com/user_guide/tutorial/news_section.html I have add a line to show photo of news:


PHP Code:
<img src="<?=site_url('../fotografias/'.($news_item['filename']))?>"


But now I want to crop it and I don't know how use Image manipulation class

PHP Code:
$image = \Config\Services::image()
        ->withFile('/path/to/image/mypic.jpg')
        ->reorient()
        ->rotate(90)
        ->crop(10010000)
        ->save('/path/to/image/mypic_thumb.jpg'); 

Any idea?. I try to create a function, but I allways get error