本文介绍了调整动画GIF文件大小而不破坏动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我需要在不破坏动画的情况下调整动画GIF文件的大小。

I need to resize an animated GIF file without destroying the animation.

如何使用PHP进行操作?

How can I do it using PHP?

推荐答案

如果你有imagemagick访问权限,你可以这样做:

if you have imagemagick access, you can do this:

system("convert big.gif -coalesce coalesce.gif");
system("convert -size 200x100 coalesce.gif -resize 200x10 small.gif");

如果您没有system()访问权限,很可能使用imagemagick插件

this is most likely possible with the imagemagick plugin if you don't have system() access

注意:这可能会创建一个更大的文件大小,但由于合并基本上不优化图像,因此尺寸较小的图像。

NOTE: this may create a larger filesize though a smaller dimensions image due to coalescing essentially deoptimizing the image.

更新:
如果您没有ImageMagick访问权限,您应该能够使用以下步骤的组合来调整动画gif的大小(假设您有GD访问权限):

UPDATE:If you don't have ImageMagick access, you should be able to use a combination of the following steps to resize an animated gif (assuming you have GD access):


  1. 检测图像是否是动画gif:(热门答案)

  2. 将动画gif拆分为单独的帧:

  3. 调整各个帧的大小:

  4. 将帧重新组合成又一个GIF动画:

  1. Detect if the image is an animated gif: Can I detect animated gifs using php and gd? (top answer)
  2. Split the animated gif into individual frames: http://www.phpclasses.org/package/3234-PHP-Split-GIF-animations-into-multiple-images.html
  3. Resize the individual frames: http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/
  4. Recomposite the frames into an animated gif again: http://www.phpclasses.org/package/3163-PHP-Generate-GIF-animations-from-a-set-of-GIF-images.html

这肯定比ImageMagick路线密集得多,但它在技术上应该是可行的。

This is definitely much more intensive than the ImageMagick route, but it should be technically possible.

如果你让它运作,请与世界分享!

If you get it working, please share with the world!

这篇关于调整动画GIF文件大小而不破坏动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:55