我打算调整动画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();
}
答案 0 :(得分:2)
尝试
echo $animation->getImagesBlob();