Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the code make one <strong>Example.php</strong></p> <pre><code>&lt;?php include "GIFEncoder.class.php"; $frames =array(); $frames [ 0 ] = "frames/images01.gif"; $frames [ 1 ] = "frames/images01.gif"; $framed [ ] = 5; /* GIFEncoder constructor: ======================= image_stream = new GIFEncoder ( URL or Binary data 'Sources' int 'Delay times' int 'Animation loops' int 'Disposal' int 'Transparent red, green, blue colors' int 'Source type' ); */ $gif = new GIFEncoder ( $frames, $framed, 0, 2, 0, 0, 0, "url" ); /* Possibles outputs: ================== Output as GIF for browsers : - Header ( 'Content-type:image/gif' ); Output as GIF for browsers with filename: - Header ( 'Content-disposition:Attachment;filename=myanimation.gif'); Output as file to store into a specified file: - FWrite ( FOpen ( "myanimation.gif", "wb" ), $gif-&gt;GetAnimation ( ) ); */ Header ( 'Content-type:image/gif' ); echo $gif-&gt;GetAnimation ( ); ?&gt; </code></pre> <p>Now create <strong>GIFEncoder.class.php</strong></p> <pre><code>&lt;?php Class GIFEncoder { var $GIF = "GIF89a"; /* GIF header 6 bytes */ var $VER = "GIFEncoder V2.05"; /* Encoder version */ var $BUF = Array ( ); var $LOP = 0; var $DIS = 2; var $COL = -1; var $IMG = -1; var $ERR = Array ( ERR00=&gt;"Does not supported function for only one image!", ERR01=&gt;"Source is not a GIF image!", ERR02=&gt;"Unintelligible flag ", ERR03=&gt;"Does not make animation from animated GIF source", ); /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFEncoder... :: */ function GIFEncoder ( $GIF_src, $GIF_dly, $GIF_lop, $GIF_dis, $GIF_red, $GIF_grn, $GIF_blu, $GIF_mod ) { if ( ! is_array ( $GIF_src ) &amp;&amp; ! is_array ( $GIF_tim ) ) { printf ( "%s: %s", $this-&gt;VER, $this-&gt;ERR [ 'ERR00' ] ); exit ( 0 ); } $this-&gt;LOP = ( $GIF_lop &gt; -1 ) ? $GIF_lop : 0; $this-&gt;DIS = ( $GIF_dis &gt; -1 ) ? ( ( $GIF_dis &lt; 3 ) ? $GIF_dis : 3 ) : 2; $this-&gt;COL = ( $GIF_red &gt; -1 &amp;&amp; $GIF_grn &gt; -1 &amp;&amp; $GIF_blu &gt; -1 ) ? ( $GIF_red | ( $GIF_grn &lt;&lt; 8 ) | ( $GIF_blu &lt;&lt; 16 ) ) : -1; for ( $i = 0; $i &lt; count ( $GIF_src ); $i++ ) { if ( strToLower ( $GIF_mod ) == "url" ) { $this-&gt;BUF [ ] = fread ( fopen ( $GIF_src [ $i ], "rb" ), filesize ( $GIF_src [ $i ] ) ); } else if ( strToLower ( $GIF_mod ) == "bin" ) { $this-&gt;BUF [ ] = $GIF_src [ $i ]; } else { printf ( "%s: %s ( %s )!", $this-&gt;VER, $this-&gt;ERR [ 'ERR02' ], $GIF_mod ); exit ( 0 ); } if ( substr ( $this-&gt;BUF [ $i ], 0, 6 ) != "GIF87a" &amp;&amp; substr ( $this-&gt;BUF [ $i ], 0, 6 ) != "GIF89a" ) { printf ( "%s: %d %s", $this-&gt;VER, $i, $this-&gt;ERR [ 'ERR01' ] ); exit ( 0 ); } for ( $j = ( 13 + 3 * ( 2 &lt;&lt; ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x07 ) ) ), $k = TRUE; $k; $j++ ) { switch ( $this-&gt;BUF [ $i ] { $j } ) { case "!": if ( ( substr ( $this-&gt;BUF [ $i ], ( $j + 3 ), 8 ) ) == "NETSCAPE" ) { printf ( "%s: %s ( %s source )!", $this-&gt;VER, $this-&gt;ERR [ 'ERR03' ], ( $i + 1 ) ); exit ( 0 ); } break; case ";": $k = FALSE; break; } } } GIFEncoder::GIFAddHeader ( ); for ( $i = 0; $i &lt; count ( $this-&gt;BUF ); $i++ ) { GIFEncoder::GIFAddFrames ( $i, $GIF_dly [ $i ] ); } GIFEncoder::GIFAddFooter ( ); } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFAddHeader... :: */ function GIFAddHeader ( ) { $cmap = 0; if ( ord ( $this-&gt;BUF [ 0 ] { 10 } ) &amp; 0x80 ) { $cmap = 3 * ( 2 &lt;&lt; ( ord ( $this-&gt;BUF [ 0 ] { 10 } ) &amp; 0x07 ) ); $this-&gt;GIF .= substr ( $this-&gt;BUF [ 0 ], 6, 7 ); $this-&gt;GIF .= substr ( $this-&gt;BUF [ 0 ], 13, $cmap ); $this-&gt;GIF .= "!\377\13NETSCAPE2.0\3\1" . GIFEncoder::GIFWord ( $this-&gt;LOP ) . "\0"; } } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFAddFrames... :: */ function GIFAddFrames ( $i, $d ) { $Locals_str = 13 + 3 * ( 2 &lt;&lt; ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x07 ) ); $Locals_end = strlen ( $this-&gt;BUF [ $i ] ) - $Locals_str - 1; $Locals_tmp = substr ( $this-&gt;BUF [ $i ], $Locals_str, $Locals_end ); $Global_len = 2 &lt;&lt; ( ord ( $this-&gt;BUF [ 0 ] { 10 } ) &amp; 0x07 ); $Locals_len = 2 &lt;&lt; ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x07 ); $Global_rgb = substr ( $this-&gt;BUF [ 0 ], 13, 3 * ( 2 &lt;&lt; ( ord ( $this-&gt;BUF [ 0 ] { 10 } ) &amp; 0x07 ) ) ); $Locals_rgb = substr ( $this-&gt;BUF [ $i ], 13, 3 * ( 2 &lt;&lt; ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x07 ) ) ); $Locals_ext = "!\xF9\x04" . chr ( ( $this-&gt;DIS &lt;&lt; 2 ) + 0 ) . chr ( ( $d &gt;&gt; 0 ) &amp; 0xFF ) . chr ( ( $d &gt;&gt; 8 ) &amp; 0xFF ) . "\x0\x0"; if ( $this-&gt;COL &gt; -1 &amp;&amp; ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x80 ) { for ( $j = 0; $j &lt; ( 2 &lt;&lt; ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x07 ) ); $j++ ) { if ( ord ( $Locals_rgb { 3 * $j + 0 } ) == ( ( $this-&gt;COL &gt;&gt; 16 ) &amp; 0xFF ) &amp;&amp; ord ( $Locals_rgb { 3 * $j + 1 } ) == ( ( $this-&gt;COL &gt;&gt; 8 ) &amp; 0xFF ) &amp;&amp; ord ( $Locals_rgb { 3 * $j + 2 } ) == ( ( $this-&gt;COL &gt;&gt; 0 ) &amp; 0xFF ) ) { $Locals_ext = "!\xF9\x04" . chr ( ( $this-&gt;DIS &lt;&lt; 2 ) + 1 ) . chr ( ( $d &gt;&gt; 0 ) &amp; 0xFF ) . chr ( ( $d &gt;&gt; 8 ) &amp; 0xFF ) . chr ( $j ) . "\x0"; break; } } } switch ( $Locals_tmp { 0 } ) { case "!": $Locals_img = substr ( $Locals_tmp, 8, 10 ); $Locals_tmp = substr ( $Locals_tmp, 18, strlen ( $Locals_tmp ) - 18 ); break; case ",": $Locals_img = substr ( $Locals_tmp, 0, 10 ); $Locals_tmp = substr ( $Locals_tmp, 10, strlen ( $Locals_tmp ) - 10 ); break; } if ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x80 &amp;&amp; $this-&gt;IMG &gt; -1 ) { if ( $Global_len == $Locals_len ) { if ( GIFEncoder::GIFBlockCompare ( $Global_rgb, $Locals_rgb, $Global_len ) ) { $this-&gt;GIF .= ( $Locals_ext . $Locals_img . $Locals_tmp ); } else { $byte = ord ( $Locals_img { 9 } ); $byte |= 0x80; $byte &amp;= 0xF8; $byte |= ( ord ( $this-&gt;BUF [ 0 ] { 10 } ) &amp; 0x07 ); $Locals_img { 9 } = chr ( $byte ); $this-&gt;GIF .= ( $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp ); } } else { $byte = ord ( $Locals_img { 9 } ); $byte |= 0x80; $byte &amp;= 0xF8; $byte |= ( ord ( $this-&gt;BUF [ $i ] { 10 } ) &amp; 0x07 ); $Locals_img { 9 } = chr ( $byte ); $this-&gt;GIF .= ( $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp ); } } else { $this-&gt;GIF .= ( $Locals_ext . $Locals_img . $Locals_tmp ); } $this-&gt;IMG = 1; } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFAddFooter... :: */ function GIFAddFooter ( ) { $this-&gt;GIF .= ";"; } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFBlockCompare... :: */ function GIFBlockCompare ( $GlobalBlock, $LocalBlock, $Len ) { for ( $i = 0; $i &lt; $Len; $i++ ) { if ( $GlobalBlock { 3 * $i + 0 } != $LocalBlock { 3 * $i + 0 } || $GlobalBlock { 3 * $i + 1 } != $LocalBlock { 3 * $i + 1 } || $GlobalBlock { 3 * $i + 2 } != $LocalBlock { 3 * $i + 2 } ) { return ( 0 ); } } return ( 1 ); } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFWord... :: */ function GIFWord ( $int ) { return ( chr ( $int &amp; 0xFF ) . chr ( ( $int &gt;&gt; 8 ) &amp; 0xFF ) ); } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GetAnimation... :: */ function GetAnimation ( ) { return ( $this-&gt;GIF ); } } ?&gt; </code></pre> <p>Place <strong>images01.gif</strong> and <strong>images02.gif</strong> in frames folder beside this two files</p> <p>Now Run Example.php</p> <p>You can also download code from her</p> <p><a href="http://www.phpclasses.org/browse/package/3163.html?download=zip" rel="nofollow">Download Link</a></p> <p>I have tried this and it works.</p> <p>with regards </p> <p><strong>Wasim</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload