I want to retrieve the image from a URL, change it again and save it in the folder.
I have this code to get the image from the url:
$ url = 'http://www.example.com/image/test.jpg'; $ Img = 'images / newtest.jpg'; File_put_contents ($ img, file_get_contents ($ url)); The problem is that before I file_put_contents , I want to resize the image. How can I do this with PHP? Please help me, I searched the internet, but ended up with a vague explanation.
Here's how you can do that Image Magic is being installed on your server ...
$ url = 'http://www.example.com/image/test.jpg'; $ Img = 'images / newtest.jpg'; File_put_contents ($ img, file_get_contents ($ url)); $ Image = new imagic ($ img); $ Imageprops = $ image- & gt; GetImageGeometry (); If ($ imageprops ['width'] & lt; = 200 & amp; amp; $ imageprops ['height]] & lt; = 200) {// upscale} else {$ image- & gt; ResizeImage (200,200, fiction: FILTER_LANCZOS, 0.9, true); }
Comments
Post a Comment