
Thomas Haxton - 2015-05-01 19:48:24
Laszlo, thanks for making this nice PHP class. I would like to use it to create image resources for each frame that can be used as a parameter in imagecolorat. But my naive attempt to do so didn't work. So instead, I a write a file for each frame and then read it. Below is the working code, with what I would like to do commented out. If anyone knows how to do this, please let me know. Thanks!
include_once ("gifsplit-2009-07-03/GIFDecoder.class.php" );
$gifDecoder = new GIFDecoder ( fread ( fopen ( $animation, "rb" ), filesize ( $animation ) ) );
$frame = 0;
foreach ( $gifDecoder -> GIFGetFrames ( ) as $frameimage ) {
// I would like to just do this:
// $image = $frameimage
// But it doesn't work: Imagecolorat expects resource, string given
// Instead, create temporarily files for each frame, then read the file to create image resource
$file = "tmpframe.gif";
fwrite ( fopen ( $file , "wb" ), $frameimage );
$image = ImageCreateFromGif($file);
$size = GetImageSize($animation);
$width = $size[0];
$height = $size[1];
for ($i = 0; $i < $height; $i++) {
for ($j = 0; $j < $width; $j++) {
$palette_index = ImageColorAt($image, $j, $i);
}
}
}