1

I intend to resize an animated gif and output 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();
}
Tchoupi
  • 14,560
  • 5
  • 37
  • 71
Freeman
  • 321
  • 3
  • 14

1 Answers1

3

try it with

echo $animation->getImagesBlob();
somename
  • 31
  • 2