JC Nolan - 2008-08-13 21:31:04
I am interested in generating my image data (cells) on the fly and then implementing them into an animated gif. I supposed that I could create an array of images using the gd imageCreate() function, but no luck. GIFEncoder reports that the data supplied is not an image.
The closest I've been able to do, which works, is to spool each frame to a temporary directory using the imagegif() command and then reference the filename.
include "GIFEncoder.class.php";
for ($c = 1; $c<14; $c++) {
$image = getImage($c); // Produces an image with a number on it
imagegif($image,'dump/'.$c.'.gif');
$frames[] = 'dump/'.$c.'.gif'; // Would prefer to save image here, not filename
$time[] = 100; // equals frame time (100 = 1 second)
}
// encode the gif using the class to avoid gd dependencies
$gif = new GIFEncoder (
$frames, // frames array
$time, // elapsed time array
0, // loops (0 = infinite)
2, // disposal
0, 0, 0, // rgb of transparency
"url" // source type
);
// display the image
Header ( 'Content-type:image/gif' );
echo $gif->GetAnimation ( );
// Anybody got any recomendations? Also, how can I write out the Animated gif? Will imagegif() work for that as well?