Imagemagick gif 和覆盖 png 图像

Imagemagick gif and overlaying png image

我有一个 GIF animation with unknown size and a PNG 600x400 with transparent elements. How can I get a GIF like this 的 600x400、裁剪 GIF 和使用 Imagemagick 制作动画?

使用 Imagemagick,您需要在 gif 上进行合并(以填充完整的帧)和图层合成以将动画 gif 与静态图像结合起来。使用 Imagemagick 6.9.10.9 Q16 Mac OSX,它将是:

convert JN6W6.gif -coalesce -resize 600x400 null: PAiVp.png -gravity center -layers composite -layers optimize JN6W6_PAiVp_1.gif


modified by resize only

如果您只想将其裁剪为 600x400,则

convert JN6W6.gif -coalesce -background white -gravity center -extent 600x400 +repage null: PAiVp.png -gravity center -layers composite -layers optimize JN6W6_PAiVp_2.gif


modified by simply cropping using -extent

如果您想要调整大小然后裁剪,

convert JN6W6.gif -coalesce -resize 600x400^ -gravity center -crop 600x400+0+0 +repage null: PAiVp.png -gravity center -layers composite -layers optimize JN6W6_PAiVp_3.gif


modified by resizing and cropping

null: 在此处理中需要作为分隔符。

https://www.imagemagick.org/Usage/anim_mods/#composite

如果使用 Imagemagick 7,请将 convert 替换为 magick。