Php 使用imagick将调整大小的动画gif输出到浏览器
我打算调整动画gif的大小,并将其动态输出到浏览器。我的问题是,当我保存已调整大小的图像时,它的质量很好,但如果我将其回送到浏览器,则质量很差,动画将被删除。代码如下:Php 使用imagick将调整大小的动画gif输出到浏览器,php,imagemagick,gif,imagick,Php,Imagemagick,Gif,Imagick,我打算调整动画gif的大小,并将其动态输出到浏览器。我的问题是,当我保存已调整大小的图像时,它的质量很好,但如果我将其回送到浏览器,则质量很差,动画将被删除。代码如下: header("Content-type:image/gif"); try { /*** Read in the animated gif ***/ $animation = new Imagick("images/nikks.gif"); /*** Loop through the frames **
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();
}
试一下
echo $animation->getImagesBlob();