|
|
 qianxiaoqian - 2007-03-23 10:31:03
Hello László,
Tnank you for your codes,that's really useful.
I find the GIFDecoder.class.php in your site (gifs.hu),but I can't find any description about how to use it.
So could you please show me some sample codes,
Or could you share the your codes for
gifs.hu/phpclasses/demos/GifBuilder ...
thanks again.
 László Zsidi - 2007-03-25 20:03:39 - In reply to message 1 from qianxiaoqian
Hi,
Thank you for your feedback.
To use of GIFDecoder.class.php is very easily.
<?php
$decoder = new GIFDecoder ( "animated.gif" );
$frames = decoder->GIFGetFrames ( );
for ( $i = 0; $i < count ( $frames ); $i++ ) {
$fname = ( $i < 10 ) ? "frame0$i.gif" : "frame$i.gif";
fwrite ( fopen ( $fname, "wb" ), $frames [ $i ] );
}
?>
 Sai'd - 2007-04-25 10:14:03 - In reply to message 2 from László Zsidi
I use the class as the way you descripe but i got an infinit loop in the section
switch ( $this->GIF_buffer [0] )
since the value of buffer allway does not handle by any case ????
How could I fix it Plz
 Bauer - 2007-05-05 16:27:08 - In reply to message 3 from Sai'd
It's hard to find a PHP library to simply extract frames from animated gif file. Thanks for for your help, László.
To help Said, here is the adapted code fully working with gifdecoder class.
<?
require_once("lib/gifdecoder.class.php");
$FIC="anim_fr.gif";
if(file_exists($FIC))
{
$GIF_frame = fread (fopen ($FIC,'rb'), filesize($FIC));
$decoder = new GIFDecoder ($GIF_frame);
$frames = $decoder->GIFGetFrames();
for ( $i = 0; $i < count ( $frames ); $i++ )
{
$fname = ( $i < 10 ) ? $FIC."_0$i.gif" : $FIC."_$i.gif";
$hfic=fopen ( "output/".$fname, "wb" );
fwrite ($hfic , $frames [ $i ] );
fclose($hfic);
}
}
?>
 László Zsidi - 2007-05-06 20:27:46 - In reply to message 3 from Sai'd
Hi,
Seems to be your animated GIF has an incorrect image data.
All GIF images containts an Extension block begin at byte 0x21 or a
Descriptor block begin at byte 0x2C or booth and an EOF at byte 0x3B.
I just thought the EOF byte is missing in your animated GIF in the same the most popular image viewer can be played.
If this byte missing the "for ( $cycle = 1; $cycle; ) { }" cycle will be infinity.
Please look over your GIF image by a Hex editor and searching for existing of this byte ( 0x3B )
 László Zsidi - 2007-05-06 20:35:36 - In reply to message 3 from Sai'd
Made a little modification for GIFDecoder.class.php
Can be found here: http://gifs.hu/phpclasses/show.php?src=GIFDecoder.class.php
 László Zsidi - 2007-05-06 20:51:18 - In reply to message 4 from Bauer
Dear Bauter!
Thank you!
 eddy ammar - 2007-07-04 11:02:25 - In reply to message 7 from László Zsidi
Dear László,
Thanks a lot for quality scripts that you've made so far. I've been using them & love them!
For this GIFDecoder class, is it possible for you to get the delay information from each frame? If so, would you be kind enough to add this in your class?
The reason for this is I need to reconstruct the frames back into its original animation after I manipulate them, so I need to know the exact delays for each of them.
Thank you so much for your time László.
 László Zsidi - 2007-07-04 20:29:12 - In reply to message 8 from eddy ammar
Dear Eddy,
We will working together with Simon Thomas to make a solution for this function.
We would like to implement into the exists GIFEncoder class as an extended function what can be used to pass delays of original frames into an array.
Laszlo
 László Zsidi - 2007-07-04 22:31:53 - In reply to message 8 from eddy ammar
Ok guys,
I have implemented a new function into GIFDecoder.class.php what can be used to determine and pass into an array the originaly delays between frames.
Download page permanenty at http://gifs.hu/phpclasses/show.php?src=GIFDecoder.class.php
Use this function:
<?php
$fp = fopen ( "test.gif", "rb", filesize ( "test.gif" ) );
$gif = new GIFDecoder ( $fp );
$dly = $gif->GIFGetDelays ( );
for ( $i = 0; $i < count ( $dly ); $i++ ) {
printf ( "Delay of %d frame is %d ms<br>", $i, ( $dly [ $i ] * 10 /* milliseconds */ ) );
}
?>
|