アニメーション 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();
}