PHP Classes

Error creating a GIF

Recommend this page to a friend!

      GIF images into animated GIF with native PHP class  >  All threads  >  Error creating a GIF  >  (Un) Subscribe thread alerts  
Subject:Error creating a GIF
Summary:gif creation
Messages:5
Author:antoine
Date:2008-06-09 15:10:26
Update:2008-06-29 10:57:56
 

  1. Error creating a GIF   Reply   Report abuse  
Picture of antoine antoine - 2008-06-09 15:10:26
hi anyone
szia László

little problem for me...


i'm trying to create an animated gif with some non-animated gif


i have some gif into $path directory:
0.gif
1.gif
2.gif
3.gif...


this is how i make the array[]:


if ($dh=opendir($path)){
for ($i=0;$i<$counter;$i++){
$frames[$i]=$path. $i . ".gif";
$framed[$i]=100;
echo"Slide[$i]=$frames[$i]-Framed[$i]=$framed[$i]<br>";
}
closedir($dh);
}

i think this is correct, and so, now i create the gif

$gif = new GIFEncoder ( $frames,
$framed,
0,
2,
0, 0, 0,
"url"
);


than...
echo $gif->GetAnimation( );




so... why when i create the gif this is what it returns to me?

GIF89a2&#65533;2&#65533;&#65533;&#65533;&#65533;hvTt"$:< tD!&#65533;&#65533;&#65533;&#65533;J&#65533;qB&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;DV4&#65533;&#65533;&#65533;$! &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;]%&#65533;&#65533;&#65533;&#65533;nD &#65533;&#65533;&#65533;>M.&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;{O,&#65533;&#65533;T&#65533;\5x1 &#65533;&#65533;&#65533;0 &#65533;`&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;@@"&#65533;.^&#65533;h<_0&#65533;&#65533;&#65533; Q$)$0 &#65533;&#65533;j&#65533;&#65533;&#65533; 2<.i<&#65533;&#65533;&#65533;&#65533;iP&#65533;D' &#1098;g%(gY7&#65533;]>P0 l/ &#65533;U0&#65533;P0&#65533;2 44!N 4&#65533;&#1204;&#65533;U"&#65533;~L&#620;&#65533;LL4&#65533;&#65533;&#65533;&#65533;&#65533;d&#269;p.&#65533;\&#65533;"&#65533;2$&#65533;&#65533;&#65533;T0$4"\=TbT&#65533;jDlf4&#65533;&#65533;x&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#1810;|&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;\N<&#65533;&#65533;&#65533;&#65533;zQ&#65533;&#65533;&#65533;&#802;l&#65533;iD&#65533;jDl&#65533;q&#286;|&#65533;&#65533;&#65533;ttTTY9$" &#65533;&#65533;n&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;\D(&#65533;&#65533;&#65533;&#65533;&#65533;l&#65533;jHQ&#1478;_&#65533;vT&#1326;&#65533;44 &#65533;z\L &#65533;b?6 xJ |b<&#65533;&#65533;&#65533;)6DR,D6|V46 ?F(`6&#65533;V!&#65533;&#65533;&#65533;&#65533;b@L6&#65533;&#436;&#65533;V1&#582;\&#65533;b<&#1310;t&#65533;vT&#65533;X&#65533;&#65533;&#65533;&#65533;"L6&#65533;rO&#65533;&#65533;&#65533;v/&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;'&#65533;&#65533;&#65533;&#1794;d&#65533;nPa*&#65533;&#65533;&#65533;'&#65533;|`6&#65533;p&#65533;&#65533;|D6_jL&#774;d&#65533;&#65533;`&#1310;&#65533;t*l6 4B@*4&#65533;&#65533;&#65533;&#65533;V"&#65533;&#65533;&#65533;H^L&#65533;V< &#65533;&#65533;&#65533;T<!&#65533; NETSCAPE2.0&#65533;&#65533;&#65533;!&#65533;d&#65533;&#65533;&#65533;,&#65533;&#65533;&#65533;&#65533;2&#65533;2&#65533;&#65533;&#65533;&#65533;Y&#65533;jA&#65533;E&#65533;`&#65533;&#65533;Q2&#65533;R?hR&#65533;&#65533;a `h((&#1656;QJ&#65533;v&#65533;&#65533;&#65533;&#65533;1q&#65533;&#65533;&t&#65533;&#65533;$&#65533;@&#65533;&#65533;&#65533;R&#65533;/X&#65533;b&#65533;&#65533;P&#65533;'&#65533;&#49584;&#65533;&#65533;F&#65533;F&#65533;{&#65533;&#257;&#65533;),&#2029;z&#65533;&#65533; Ah&#65533;&#65533;&#65533; &#65533;&#65533;-6&#65533;P&#65533;F[X4I$&#65533;d11 &#1357;G&#65533;&#65533;`&#65533;C&#65533; &#65533;&#65533;pHy&#65533;N&#65533;*O&#65533;!&#65533;l;q3J&#65533;$E&#542;)&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;x&#65533;C,3 E&#65533;&#65533;i&#65533;&#65533;U&#65533;&#65533;&#65533;v&#65533;V&#65533;&#65533;3&#65533;^)&#65533;%já-&#65533;f9n `a_P&#65533;&#65533;0&#65533;&#406;>,Xx&#65533;&#65533;B&#65533; &#65533;I&#65533;&#65533;&#1582;&#65533;#&#65533;&#65533;&#65533;&#65533;y R &#65533;&#65533;&#65533;_&#65533;HR&#65533;B&#65533;!0&#65533;X%&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;4&#65533;&#65533;&#65533;4&#65533;&#65533;&#65533;X&#19539;BF&#65533;L&#65533; 8&#65533;&#65533;B;&#65533; &#65533;&#65533;pI&#65533;SH&#65533;`&#65533;WD&#65533;;&#65533;)&#65533;&#65533;C&#65533;&#65533;v&#65533;G&#65533;p&#65533;M&#65533;&#65533; &#65533;&#65533;&#65533;y&#65533;>&#65533;1&#65533;&#65533;&#1704;bN1(&#65533;&#65533;&#1285;&#65533;&#65533;"&#65533;&#65533;&#65533;`0$&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;%&#65533;X&#65533;G ^PB&#65533;F*&#65533;0&#65533;&#65533;,8&#65533;&#65533;W&#65533;&#65533;&#65533;q&#65533;&#65533;Oq6&#65533;8&#65533;&#65533;&#65533;&#65533;&#65533;/&#65533;q&#65533;&#65533;!&#65533;&#65533; &#65533;&#9218;&#65533;|&#65533;)âG>&#65533;\&#65533;&#65533;&#65533;h&#65533;'-z%G&#65533;N&#65533;&#39095;4&#65533;&#65533;w&#65533;(&#1860;/&#65533;)&#65533;2&#1810;&#65533; &#65533;U&#65533;&#65533;c&#65533;&#65533;IA&#65533; &#65533;&#65533;;&#1373;z% &#65533;&#65533;&#65533;&#65533;cJx&#65533;&#65533;&#65533;)T&#65533; &#65533;&#1040;+&#65533;e;}&#65533;&#65533;&#65533;!%&#65533;\ T1 &#65533; `E-ü&#65533;&#65533;&#65533;/&#65533;&#65533;&#65533;*}hC&#65533;$&#65533;tA:&#65533;`&#65533;&#65533;h&#65533;.&#65533;&#65533;1&#65533;cR,&#65533;&#65533;&#65533;UT&#65533;K&#65533;&#1021;=&#65533;p.&#65533;&#42628;;&#65533;&#65533;&#65533;&#65533;|0"#&#65533; (&#1227;&#65533;&#65533;&#811;&#65533;&#65533;&#65533;&#65533;8&#65533;Xz&#65533;;&#65533;&#65533;a&#65533;Fp&#65533;&#65533;&#65533;<&#65533;&#65533;#&#65533;+]$S&#65533;&#65533;&#65533;s &#65533;&#65533;7S|:i&#65533;D* &#65533;&#65533;s&#65533; T&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;i&#65533;B&#65533;&#65533;&#65533;&#65533;]&#65533;&#65533;J&#65533;&#65533;&#65533;&#65533;N&#65533;!i&#65533;&#65533;&#65533;3 81 P@a&#65533;&#65533; =&#65533;&#65533;&#65533;&#1467;&#65533;&#65533;.K&#65533;&#65533;y&#65533;&#65533;N&#65533;I&#1600;PFe&#65533;8&#65533;\&#65533;O&#65533;&#65533;1_l&#65533;&#65533;j&#65533;&#65533;&#65533;5&#65533;h1I &#65533;&#65533;&#65533;&#65533;ln&#65533;0&#65533;&#65533;&#65533;pQEA&#65533;&#65533;E B&#65533;M&#65533;&#65533;t&#65533;PC&#65533;&#65533;&#65533;? &#65533;/&#65533;&#65533;\&#65533;uPS8K8s-7&#65533;F&#65533;&#65533;&#65533;3i&#811;&#65533;&#65533;z&#65533;S&#65533;1&#1842;&#65533; R&#65533;w&#65533;"&#65533;,2&#65533;+&#65533;T&#65533;C &#65533;B&#65533;a&#65533;^3&#65533;5Y8&#65533;&#65533;&#65533;&#65533;Q7&#65533;&#65533;y*z&#65533;*\4&#65533;;h&#65533;&#37381;/&#65533;&#65533;&#65533; "&#65533;0(&#65533;0&#65533; D&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;,d&#65533;0&#65533;&#1778;t&#65533;,"&#65533;K&#65533;>1 ID`&#65533;h&#65533; &#65533;'T&#65533;N8 &#65533;Ae{r&#65533;!&#65533;P&#65533;n &#65533;VK&#65533;&#65533;-&#65533;p&#65533;^&#65533;&#65533;&#65533;&#65533;&#65533;A&#65533;&#65533;&#65533;x5&#65533; &#65533;&#65533;(&#65533; &#65533;&#65533;B-|&#65533;K&#65533;&#65533;&#65533;0A &#65533;&#65533;&#65533; &#1280;P&#65533;&#65533;&#65533;C=&#65533;&#65533;&#65533;&#65533;E&#65533;e*@&#65533;&#65533;&#65533;&#65533;&#65533;S&#65533;&#65533;?&#65533;&#65533; 8P &#65533;&#65533; 0&#65533;&#65533;+&#65533;&#65533;&#65533;:&#65533;^07d`)&#65533;&#65533; &1 ct&#65533;&#65533;&#65533;&#65533;&#65533;Đ&#65533;\&#65533;&#65533;<&#65533;F"&#65533;! e&#65533;&#65533;&#65533;H&#65533;(C;&#65533; `&#65533;h&#65533;&#65533;C v&#65533;Dx#B&#65533;*&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;;&#65533;&#65533;HS '&#65533;E5&#65533;@#&#65533;&#65533;&#65533;&#65533;&#65533;8Q&#65533;*<&#65533;Ü&#65533;z&#65533;2&#65533; q&#65533;&#65533;ZPAz&#65533;&#65533;A ,P&#65533;T&#65533;&#65533;&&#1315;&#65533; &#65533;&#65533;azl&#65533;~&#65533;j&#65533;;&#65533;&#65533;&#65533;&#65533;x&#65533;&#65533;&#65533;&#65533;&#65533;~JB &#65533;&#515;,&#65533;{&#65533;a&#760;&#1648;'&#65533;&#65533;&#65533;^&#65533;&#65533;&#65533;7Up ]&#65533;&#65533;1&#65533;5X&#65533;&#65533;&#1465;h#&#65533;&#65533;E2&#65533;` &#65533;&#65533;'2&#65533;3&#65533;&#1027;^&#65533;&#65533;' &#65533; &#65533;!&#65533;c&q&#65533;F &#1024; &#65533;&#65533;Y6"&#65533;%&#65533;@ y&#515;2N&#1035;&#65533; &X&#1120;&#568;&#65533; B &#65533;H&#65533;&#65533;Q$&#65533;&#65533;2&#65533;&#65533; b@&#65533;Rz&#65533;M&#65533;&#65533;A&#1056;&#65533;&#65533; &#65533;X D&#1536;'&#65533;x&#65533; &#65533;`&#65533; &#65533;&#65533;]&#1363;&#65533;&#65533;q&#65533;&#65533; &#65533;&#65533;h?&#65533;&#65533; I&#65533;A &#65533;&#65533;&#65533; &#65533;&#65533;@&#65533;j&#65533;{&#65533;>8&#65533;y&#65533;)&#1936;&#65533;<&#65533;&#65533;f=A&#65533;&#1094;;h@&#65533;*&#65533;&#65533;&#65533;z&#65533;&#65533;&#65533;1&#65533;B&#65533;&#65533;#! NF&#65533;&#65533;C&#65533;&#65533;&#65533;@&#65533;Q&#65533;]D&#65533; &#65533;&#65533;?b&#65533;z4kO&#65533;&#65533;&#65533;P&#65533;T &#65533;HG8>&#65533;=&#65533;m&#65533;84a s&#65533;=&#65533; 6&#65533;F&#65533;i]&#65533;.........................

and on...

why?
any idea?

thanks a lot

regards
antonio

  2. Re: Error creating a GIF   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2008-06-12 05:22:44 - In reply to message 1 from antoine
Hmmm...it's very interesting:)

A way for a simplified solution is:

<?php
$path = "\images\frames\";
$f = array ( );
$t = array ( );
for ( $i = 0; $i < 5; $i++ ) {
sprintf ( $f [ ], "%s%d.gif", $path, $i );
$t [ ] = 10;
}
/* older version */ $GIF = new GIFEncoder ( $f, $t, 0, 2, -1, -1, -1, "url" );
/* 3.0 version */ $GIF = new GIFEncoder ( $f, $t, 0, 2, -1, -1, -1, array ( ), "url" );
header ( 'Content-type:image/gif' );
echo $GIF->GetAnimation ( );
?>

  3. Re: Error creating a GIF   Reply   Report abuse  
Picture of antoine antoine - 2008-06-27 16:37:27 - In reply to message 2 from László Zsidi
szia laszlo


i'm still in troubles

my gif files are in \new_img folder
\new_img\0.gif
\new_img\1.gif
\new_img\2.gif
...


this is my code:



$path="new_img\\"
$f = array ( );
$t = array ( );

for ( $i = 0; $i < $counter ; $i++ ) {
$f [$i] = "$path$i.gif";
$t [$i] = 75;
}
$GIF = new GIFEncoder ( $f, $t, 0, 2, -1, -1, -1, "url" );
header ( 'Content-type:image/gif' );
echo $GIF->GetAnimation ( );





but i have this error code now:

Warning: Cannot modify header information - headers already sent by (output started at C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\php\make.php:9) in C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\php\make.php on line 49
GIF89a;



why?

  4. Re: Error creating a GIF   Reply   Report abuse  
Picture of antoine antoine - 2008-06-28 09:46:14 - In reply to message 3 from antoine
sorry once again...

but the warning is not the problem


i edited with a notepad the frames you use in your Example.php



those frames are all like this:

GIF89aę < ÷ Ž



the gif i have to merge are all like this:

GIF89a2 2 ç





note that i created my gif with these php function:



$tmpimg=imagecreatetruecolor(50,50);

imagecopyresized($tmpimg,$srcimg,0,0,$x1,$y1,50,50,$src_w,$src_h);

imagegif($tmpimg,$file2,80);







so... fact is that my gif seems to be un-readable or incompatible with you GIFEncoder.class.php



any suggest?




thanks a lot

  5. Re: Error creating a GIF   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2008-06-29 10:57:56 - In reply to message 4 from antoine
Seems to be sent the html header multiple...
Review your code and search Header(); functions multiple.