downloading remote images [SOLVED]
Posted: Mon Oct 01, 2007 3:11 am
I've a script, which allows users to input images for use in the web page along with simple HTML. However for bandwidth and accessability reasons, I've made it so the script grabs all of the jpg, png, gif images and transfers them to our server. Thus, site users won't see "bandwidth exceeded" or downtime of other 3rd party free image hosting solutions (e.g. photobucket, imageshack, tinypic).
Using GD imagejpeg(), imagegif(), and imagepng() functions, I can save them to the path I want on our server, then replace the image links in the submitted code and all works as expected.
Except for animated .gif's. I didn't really think about it, but I suppose that is still a limitation on the GD imaging software. Only the first frame is written.
The solution I've come up with is to simply grab the contents of the image and write it to a raw file. e.g.
This feels hackish to me. Or is it the only way of accomplishing the download and storage of animated gifs?
EDIT| Copyright issues shouldn't be a problem.
As the images are going to be made of images they've taken, made, or found from open source directories or royalty free imagery web sites.
Using GD imagejpeg(), imagegif(), and imagepng() functions, I can save them to the path I want on our server, then replace the image links in the submitted code and all works as expected.
Except for animated .gif's. I didn't really think about it, but I suppose that is still a limitation on the GD imaging software. Only the first frame is written.
The solution I've come up with is to simply grab the contents of the image and write it to a raw file. e.g.
Code: Select all
$file = file_get_contents($imgLink);
$handle = fopen('images/display/' . $newImageName, "w");
fwrite($handle, $file);
fclose($handle);EDIT| Copyright issues shouldn't be a problem.