【发布时间】:2015-04-19 19:36:54
【问题描述】:
我查看了不同的问题(例如this 或this)和php documentation。我检查了我的 Imagick 版本并且 imagick::getVerison() 函数返回
{"versionNumber":1641,"versionString":"ImageMagick 6.6.9-7 2014-03-06 Q16 http:\/\/www.imagemagick.org"}
所以我没有使用问题和文档中提到的错误版本(或者至少我不认为我是)。我正在使用以下代码尝试调整 gif 的大小。
public function resizeGif($path, $x, $y, $maintainRation = true) {
$imageObject = new Imagick($path);
$format = $imageObject->getImageFormat();
if ($format != "GIF") {
return false;
}
$imageObject = $imageObject->coalesceImages();
$y = $this->getAspectRation($imageObject->getImageWidth(),
$imageObject->getImageHeight(),
$x);
foreach ($imageObject as $frame) {
$frame->thumbnailImage($x, $y);
$frame->setImagePage($x, $y, 0, 0);
}
$newImageDir = 'img' . rand();
$imageObject = $imageObject->deconstructImages();
$imageObject->writeImages($newImageDir, true);
$md5 = md5_file($newImageDir);
return $md5;
}
但是当我运行该函数时,会创建 gif 并调整其大小,但没有动画。 this is the image I'm testing with
【问题讨论】: