我打算调整动画 gif 的大小并将其即时输出到浏览器。我的问题是,当我保存调整大小的图像时,它的质量很好,但如果我echo
将它保存到浏览器,它的质量很差并且动画被删除。这是代码:
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();
}