Outputing resized animated gif to browser using imagick

Posted by Freeman on Stack Overflow See other posts from Stack Overflow or by Freeman
Published on 2010-06-12T11:47:18Z Indexed on 2010/06/12 11:52 UTC
Read the original article Hit count: 288

Filed under:
|
|

I intent to resize an animated gif and outputing it to the browser on-the-fly. My problem is that when I save the resized image it is of good quality, but if I echo it to the browser it is of poor quality and the animation is removed. Here is the code:`

header("Content-type:image/gif"); try { /* Read in the animated gif */ $animation = new Imagick("images/nikks.gif");

/*** Loop through the frames ***/
foreach ($animation as $frame)
{
    /*** Thumbnail each frame ***/
    $frame->thumbnailImage(200, 200);

    /*** Set virtual canvas size to 100x100 ***/
    $frame->setImagePage(200, 200, 0, 0);
}

/*** Write image to disk. Notice writeImages instead of writeImage ***/
//$animation->writeImages("images/nikkyo1.gif",true);

echo $animation;

} catch(Exception $e) { echo $e->getMessage(); } `

© Stack Overflow or respective owner

Related posts about php

Related posts about imagemagick