使用imagemagick和php调整动画gif的大小

时间:2011-03-19 07:11:07

标签: php image imagemagick gif

我正在使用此脚本使用imagemagick和php调整gif的大小:(使用php Imagick扩展):http://www.phpro.org/examples/Thumbnail-From-Animated-GIF.html

问题在于,如果gif有很多帧,那么调整每个帧大小的过程非常严重,需要几分钟才能完成请求。

我找到了这两个imagemagick命令:

convert big.gif -coalesce coalesce.gif
convert -size 200x100 coalesce.gif -resize 200x10 small.gif

但是我不知道如何将它们实现到Imagick扩展,因为它们是原始命令。这些命令会加快GIF转换的过程吗?

2 个答案:

答案 0 :(得分:1)

您可以执行该命令购买

exec('convert big.gif -coalesce coalesce.gif', $output);
exec('convert -size 200x100 coalesces.gif -resize 200x10 small.gif', $output);

$ output将带回命令行结果。 exec()是php中用于执行命令/ bash行命令的函数。 有关该功能的更多信息和说明,请参阅以下内容。 http://php.net/manual/en/function.exec.php

答案 1 :(得分:1)

PHP.net上的示例是我发现的唯一一个实际上将帧时间保留在GIF中的代码。