Jabop Posted June 18, 2008 Share Posted June 18, 2008 I have looked around the web, but can't find any information on why this successfully outputs a gif image, but fails on the animation. <?php header("Content-type: image/gif"); $img=imagecreatefromgif($AnimatedGif); imagegif($img); imagedestroy($img); ?> Could anyone lend some assistance? Link to comment https://forums.phpfreaks.com/topic/110684-imagecreatefromgif-and-imagegif/ Share on other sites More sharing options...
DarkWater Posted June 18, 2008 Share Posted June 18, 2008 I don't think PHP can do animations properly, but I could be wrong. =/ I'll do some searching. Link to comment https://forums.phpfreaks.com/topic/110684-imagecreatefromgif-and-imagegif/#findComment-567832 Share on other sites More sharing options...
PFMaBiSmAd Posted June 18, 2008 Share Posted June 18, 2008 The GD library functions only operate on one image at a time. To process animated gifs, you would need to use one of the existing classes (or write your own). If you are only reading and outputting the image file without any processing, there is no need to go through the GD functions. Link to comment https://forums.phpfreaks.com/topic/110684-imagecreatefromgif-and-imagegif/#findComment-568173 Share on other sites More sharing options...
Jabop Posted June 18, 2008 Author Share Posted June 18, 2008 What would you propose I do then? I messed around with fopen() and tried to get something to work using that method, but I thought gd would be easier. Link to comment https://forums.phpfreaks.com/topic/110684-imagecreatefromgif-and-imagegif/#findComment-568176 Share on other sites More sharing options...
PFMaBiSmAd Posted June 18, 2008 Share Posted June 18, 2008 If you are only outputting the image, after your content-type header, any of the following would work - readfile($AnimatedGif); $contents = file_get_contents($AnimatedGif); echo $contents; $handle = fopen($AnimatedGif, "rb"); $contents = fread($handle, filesize($AnimatedGif)); fclose($handle); echo $contents; If you have code that does not work, post it and the symptoms/errors to get help with what it is or is not doing. Link to comment https://forums.phpfreaks.com/topic/110684-imagecreatefromgif-and-imagegif/#findComment-568217 Share on other sites More sharing options...
Jabop Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks PFMaBiSmAd. I tried the third option because I understood it the most off the bat, however, I don't have time to do benching on the other two methods right now. Which would be processed fastest? Which is the best method to use? Link to comment https://forums.phpfreaks.com/topic/110684-imagecreatefromgif-and-imagegif/#findComment-568223 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.