rckehoe Posted April 29, 2009 Share Posted April 29, 2009 I have just a question.... 1) Can the GD Image library get an image from a given URL and then resize it, then save it to my local server? The main question would be, does it support the URL passing, or does the image have to be local? Link to comment https://forums.phpfreaks.com/topic/156183-gd-image-library-question-url/ Share on other sites More sharing options...
Axeia Posted April 29, 2009 Share Posted April 29, 2009 if gd itself can't, look into curl. Try feeding an url though, a lot of functions work quite fine with it (when server settings allow it) Link to comment https://forums.phpfreaks.com/topic/156183-gd-image-library-question-url/#findComment-822214 Share on other sites More sharing options...
rckehoe Posted April 29, 2009 Author Share Posted April 29, 2009 curl cannot resize an image, can it? The whole point of what I am doing is to be able to resize the image, then save it on the server, so I don't have to download the image, then resize, then re-save it back to the server and delete the old one... I just think that is way to many steps and will take longer to execute the code. Link to comment https://forums.phpfreaks.com/topic/156183-gd-image-library-question-url/#findComment-822221 Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 29, 2009 Share Posted April 29, 2009 cUrl can be used to download a image into a $variable just like file_get_contents. Like this : <?php $image = file_get_contents('http://www.example.com/image.gif'); $im = imagecreatefromstring($image); .... /* resize / save the thumb */ .... imagedestroy($im); ?> You can use cUrl to do the same jobs but with better error handling than file_get_contents. Axeia have told that if gd functions can't read a URL like this : <?php $im = imagecreatefromjpeg('http://www.example.com/image.jpg'); ... ?> You can use others function to pull the image, like file_get_contents or cUrl. Link to comment https://forums.phpfreaks.com/topic/156183-gd-image-library-question-url/#findComment-822303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.