first run:
convert do.gif -coalesce temporary.gif
then
convert -size <original size> temporary.gif -resize 24x24 smaller.gif
为了方便在线交流,高清大图的GIF往往需要改小,如果逐帧修改则太麻烦.
ImageMagick中的convert可以完成这个工作,
11 |
first run:
then
|
但是效率低而且输入的命令比较复杂,参考同一链接下的方法
| |||
|
Note that the coalesced view is much larger than the optimized one (3.2 times in my test), and the resizing produces a coalesced image, which can also be larger than the original in file size (2.3 times in my test) even if the resolution is smaller. When I try resizing directly it looks fine and has a small file size, though maybe it just works for this image.
–
endolith
Dec 27 '14 at 21:49
|
居然是从ANSYS里面找到了 gifsicle 这个文件, 然后果然效果又快又好!
例子: 原始的GIF文件因为大于2MB而不能上传,改小之后OK
不过gifscicle虽然提高了速度,但是在稳健性方面比convert果然差一些;
实际使用发现,在个别gif转化中gifscicle会使导出图片有发花的效果,而convert无这种不良现象.
比如:
convert得到的结果:
gifsicle得到的结果:
(后来升级到最新的gifsicle没有这个问题了,而且gif优化得很好)
用Python应该也可以实现,
有时候不喜欢原始GIF图片中的太多无内容的margin, 则还可以用convert实现crop之:
convert input.gif -coalesce -repage 0x0 -crop WxH+X+Y +repage output.gif
-coalesce
rebuilds the full frames.-repage 0x0
. +repage
after the crop will do this.类似地gifsicle也能完成同样工作,但是,同样需要谨慎使用:
a program called Gifsicle and it works great for manipulating animated gifs.
gifsicle --crop 0,0-100,100 input.gif >output.gif
It can also do all sorts of other operations. Check it out!
关于ImageMagick的系列命令和用法,CSDN博客上还有其它的介绍:
关于 gifsicle 不得不提的两个链接:
1. Github: https://github.com/kohler/gifsicle
2. Homepage: http://www.lcdf.org/gifsicle/
设置延迟,和添加
-coalesce
"creates a complete view of the animation at each point, a bit like a true film strip, rather than an animation sequence. Such a sequence, known as a Coalesced Animation is much easier to study, edit, modify and re-optimize." – sam Aug 12 '13 at 19:26