PHP Classes

Using the "bin" source type

Recommend this page to a friend!

      GIF images into animated GIF with native PHP class  >  All threads  >  Using the "bin" source type  >  (Un) Subscribe thread alerts  
Subject:Using the "bin" source type
Summary:Can't seem to generate on the fly without writing to disk.
Messages:2
Author:JC Nolan
Date:2008-08-13 21:31:04
Update:2008-09-24 21:11:57
 

  1. Using the "bin" source type   Reply   Report abuse  
Picture of JC Nolan 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?

  2. Re: Using the "bin" source type   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2008-09-24 21:11:57 - In reply to message 1 from JC Nolan
Try out "$image = imageCreateFromString($c);" instead of "$image = getImage($c);".
I just thought that the getImage function does not processed and passed correctly into the $image variable the real image data.