How to place a GIF on another GIF, where both GIFs are of different sizes.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
raw
Posts: 1
Joined: 2018-03-27T02:30:11-07:00
Authentication code: 1152

How to place a GIF on another GIF, where both GIFs are of different sizes.

Post by raw »

I have two GIFs of different sizes. I want to be able to place a GIF2 to a background GIF1 at a specific location and at the same time add text to the result. I am new to ImageMagick world, please help.

I am trying to achieve the following result where dog sticker is in a separate GIF.

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to place a GIF on another GIF, where both GIFs are of different sizes.

Post by fmw42 »

Do the two animations have the same delays and number of frames? If not, see https://www.imagemagick.org/Usage/anim_mods/#merging.

It would help if you post your two animations and background image as well as tell us your IM version and platform.

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to place a GIF on another GIF, where both GIFs are of different sizes.

Post by fmw42 »

If your animations have the same delay and number of frames, you can do:

Background:
Image

Animation1:
Image

Animation:2
Image



Code: Select all

convert skyblue.gif \
null: \
\( morph_anim_1pt.gif -coalesce \) \
-gravity northwest -geometry +20+20 -compose over -layers composite \
null: \
morph_anim_5pts.gif \
-gravity southeast -geometry +20+20 -compose over -layers composite \
-layers optimize \
result.gif
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to place a GIF on another GIF, where both GIFs are of different sizes.

Post by fmw42 »

Perhaps this is more what you want. Imagemagick command line code in unix syntax:

The background animation has 3 frames and foreground one has 11 frames. So I repeat the background 4 times and remove the last frame so there is a total of 11 frames for the background. I coalesce the animation and add text to each frame using -annotate. Then I use -layers composite to overlay the foreground animation onto the background.

Background:
Image

Foreground:
Image


Code: Select all

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 -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
Image
Post Reply