我正在尝试使用GIFEncoder.class.php创建动画gif。
我正在使用示例中稍微修改过的代码..
include "GIFEncoder.class.php";
/*
Build a frames array from sources...
*/
$frames_k = array ('1.png','2.png');
foreach ($frames_k as $single_frame ) {
$image = imagecreatefrompng($single_frame);
$ready = imagegif($image);
$frames [ ] = $ready;
}
$framed [ ] = 2;
/*
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->GetAnimation ( ) );
*/
header ( 'Content-type:image/gif' );
echo $gif->GetAnimation ();
问题是我只得到gibbrish而不是gif ......
GIF87açÿÿÿÿÿÿŒuÿÿÿŒ¶vÿÿÿ¶Å\J„³v‡Õ˶K~ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$¡!äú_i* :f‹tJTÿÿÿÿÿÿc«éJº%/Ÿ¨5ÿÿÿÿÿÿÿÿÿË×›ÿÿÿÿÿÿ±ÅÁ„RX„:Dÿÿÿr¸ðÿÿÿÿÿÿÿÿÿ€®tÅÏp|…ÿÿÿx ¶n¤ç§¹³ÿÿÿ¢°u•±‰—¬n®ëµa•¶ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ).r„uwêJ”§Ð™1‘ ýY¢iÓ™PeJ= ufÓ¤bQUŠSjR\ŠíÚ”êسhÓª]Ëö¬Õ³*šÆ-7nD†pö|Ò›÷Sß¿|õ ÞKøoC½‡ýîy(˜ñ^Ç÷KŽ¸øadʘ/sD¬²²çÍ'+»t‹$LÓ÷J«NÍzõjÖ©Wsf]õkéÚ2y®Æ Õ¶ïÜ^ƒÇº}Û¨íªÈsFÝý,p¥Ë‘Oú»7ïç؉g¯.½»ÕºtÃþ‡ooÃæ>T/ðî]† Íûeè—£y‰÷/ÂßoäEÑüYc‘`I2$–›ƒ–$Úk¯VSj:¥´MÅÙTm$9xU‡}h¢qÈaH"‡ÜYµ\LÍ ÷–sFaGpÁ5#
第一印象是标题是错误的,所以我尝试了很多种,我也尝试过,知道以前的类似问题,将文件保存为ANSI,UTF-8没有BOM等 - 但没有任何结果..
注意:原始示例,使用gifs作为原始工作正常,我的转换来自PNG的东西是错误的。但我无法弄清楚是什么。