如何使用ImageMagick裁剪动画gif? [英] How do I crop an animated gif using ImageMagick?

查看:155
本文介绍了如何使用ImageMagick裁剪动画gif?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关裁剪图像的大量信息,但尝试裁剪(或修剪)动画会产生奇怪的结果。有时它们闪烁,或带有额外的帧,或者某些帧正确裁剪而其他帧变得偏移。如何阻止所有这些发生?

There's plenty of information about cropping images, but attempting to crop (or trim) animations produces strange results. Sometimes they flicker, or come with extra frames, or some frames crop correctly and others become offset. How do I prevent all this from happening?

推荐答案

convert input.gif -coalesce -repage 0x0 -crop WxH+X+Y +repage output.gif




  • GIF动画通常经过优化以节省空间,但在应用裁剪命令并单独处理每个帧时,imagemagick似乎并未考虑这一点。 -coalesce 重建完整的帧。

  • 其他命令会考虑原始gif中提供的偏移信息,所以你需要使用 -repage 0x0 强制重置。

  • 裁剪本身很简单,有宽度,高度,x偏移和y偏移分别提供。例如,裁剪40宽30高,x偏移50 = 40x30 + 50 + 0。

  • 裁剪不会删除从图像剪切的画布。裁剪完成后应用 + repage

    • Animated gifs are often optimised to save space, but imagemagick doesn't seem to consider this when applying the crop command and treats each frame individually. -coalesce rebuilds the full frames.
    • Other commands will take into consideration the offset information supplied in the original gif, so you need to force that to be reset with -repage 0x0.
    • The crop itself is straightforward, with width, height, x offset and y offset supplied respectively. For example, a crop 40 wide and 30 high at an x offset of 50 = 40x30+50+0.
    • Crop does not remove the canvas that it snipped from the image. Applying +repage after the crop will do this.
    • 这篇关于如何使用ImageMagick裁剪动画gif?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆