Php 从PNG图像和正确的标题创建动画GIF

Php 从PNG图像和正确的标题创建动画GIF,php,header,png,animated-gif,Php,Header,Png,Animated Gif,我正在尝试使用创建一个动画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 = imagecreatefr

我正在尝试使用创建一个动画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 ();
问题是我得到的只是胡言乱语而不是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等,但没有任何结果

注意:原始示例,使用GIF作为原始作品,好的,我从PNG转换的一些东西是错误的。但我想不出是什么