简体   繁体   English

如何使用ImageMagick(php)调整动画gif的大小?

[英]How to resize an animated gif with ImageMagick (php)?

I cannot find a working example. 我找不到有效的例子。 This one is not working, it's not animated: 这是行不通的,没有动画:

$imagick = new Imagick($_FILES['file']['tmp_name']);

$format = $imagick->getImageFormat();
if ($format == 'GIF') {
  $imagick = $imagick->coalesceImages();
  do {
     $imagick->resizeImage(500, 500, Imagick::FILTER_BOX, 1);
  } while ($imagick->nextImage());
  $imagick = $imagick->deconstructImages();
  $imagick->writeImages($name, true);

}

$imagick->clear();
$imagick->destroy();

In ImageMagick command line, this works for me 在ImageMagick命令行中,这对我有用

Original Animation: 原始动画:

在此处输入图片说明

convert animation.gif -coalesce -resize 500x500 -layers optimize -loop 0 resize.gif

在此处输入图片说明

Did you do the equivalent of -coalesce after reading your input animation? 阅读输入动画后,您是否做了-coalesce的等效功能? Did you do the optimize step after resizing? 调整大小后是否进行了优化步骤?

Sorry, I do not use PHP Imagick or any other API. 抱歉,我没有使用PHP Imagick或任何其他API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM