Jump to content

imagecreatefromgif() and imagegif()


Jabop

Recommended Posts

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

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.

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.