如何使用ImageMagick将一个大小不同的GIF放置在另一个GIF上

4
我有两个不同尺寸的GIF图像。我想能够将一个动态的GIF图像放置在静态背景GIF图像上的特定位置,并同时向结果添加文本。我是ImageMagick世界的新手,请帮忙。
我正在尝试实现以下结果,其中狗贴纸位于单独的GIF中。

enter image description here


这些图片是动画的,如果你没有注意到的话。这使得情况更加复杂,因为一个可能以每秒12帧运行,而另一个可能以每秒20帧运行。此外,覆盖的图像可能具有透明度,也可能没有。 - Mark Setchell
你需要获取每个片段的持续时间,计算帧速率的最小公倍数,将帧映射到共同的时间基准上,叠加、填充较短的片段直至与更长的片段相同长度,并重新优化...嗯,这有些麻烦。不过这是可以做到的。 - Mark Setchell
如果您发布单独的输入动画,那将会很有帮助。 - fmw42
2个回答

4
如果您的两个动画延迟时间和帧数不同,请参见https://www.imagemagick.org/Usage/anim_mods/#merging
如果您的动画延迟时间和帧数相同,则可以使用以下命令(Unix 语法):
背景: enter image description here 动画1: enter image description here 动画2: enter image description here
convert skyblue.gif \
null: \
\( morph_anim_1pt.gif -coalesce \) \
-gravity northwest -geometry +20+20 -compose over -layers composite \
null: \
\( morph_anim_5pts.gif -coalesce \) \
-gravity southeast -geometry +20+20 -compose over -layers composite \
-layers optimize \
result.gif

enter image description here

请参见https://www.imagemagick.org/Usage/anim_mods/#composite和后续章节。


3
也许这正是你想要的。以下是Unix语法下的Imagemagick命令行代码: 背景动画有3帧,前景动画有11帧。因此我将背景重复4次并删除最后一帧,以便背景总共有11帧。我合并动画并使用“-annotate”向每个帧添加文本。然后,我使用“-layers composite”将前景动画覆盖在背景上。 背景: enter image description here 前景: enter image description here
convert -delay 20 \
\( glitter_blue_tiled.gif glitter_blue_tiled.gif \
glitter_blue_tiled.gif glitter_blue_tiled.gif \
-coalesce \
+delete \
-font arial -pointsize 28 -fill black -gravity north \
-annotate +0+20 "TESTING" \) \
null: \
\( coalesced_k.gif -coalesce \) \
-gravity south -geometry +0+20 \
-compose over \
-layers composite \
-layers optimize \
-loop 0 \
result2.gif

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接