Animated gif images onto static image; undesired results

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
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Animated gif images onto static image; undesired results

Post by Don »

Hello,

My IM version is: ImageMagick 6.9.6-3 Q16 x86_64 2016-11-05
My platform is: Linux

I am trying to place more than one animated gif image onto a static image. Everything is fine(no errors) except for the result. One of the animated gif images (left arrow gif image) 'blinks' as you'll see from the resulting image. The down arrow gif image animates fine.

Here is my command:

Code: Select all

convert background.png null: \( downArrow.gif -coalesce \) -gravity Northwest -compose over -layers composite null: \( leftArrow.gif -coalesce \) -gravity SouthEast -compose over -layers composite -layers Optimize gifResult.gif
Down arrow gif image: https://www.dropbox.com/s/idups8p346ytc ... w.gif?dl=0
Left arrow gif image: https://www.dropbox.com/s/5ut4d745mdha9 ... w.gif?dl=0
Result gif image: https://www.dropbox.com/s/dsopmzlglrdw6 ... t.gif?dl=0

Is it possible to get the animated gif images to animate on the static image as intended without any blinking?

Thank you in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Animated gif images onto static image; undesired results

Post by snibgo »

The down arrow has 36 frames. The left arrow has only 28 frames. How many frames do you want in the result? Which input frames do you want to drop (or duplicate) to get that number?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Animated gif images onto static image; undesired results

Post by fmw42 »

Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Animated gif images onto static image; undesired results

Post by Don »

HI snibgo,

In order to get a smooth animation result, frames have to be dropped or duplicated to an equal amount per gif image?

Hmm not sure which to drop or duplicate. Is it possible to duplicate frames of the one with the less frames to the gif that has the most frames? So in other words, the left arrow has 28, can we add more frames to it to make it 36 frames?

Thank you. Much appreciated.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Animated gif images onto static image; undesired results

Post by snibgo »

Well, I don't know what result you want. One input cycles in 28 frames and the other cycles in 36 frames.

If you want a result with 28 frames, you need to remove 8 frames from down arrow. If you want 36 frames you need to add 8 frames to left arrow. The added frames might duplicate one or more frames, or might be blank.

Another possibility is to have 252 frames in the output. Then one cycle of the output has exactly 9 cycles of left arrow and 7 cycles of down arrow.
snibgo's IM pages: im.snibgo.com
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Animated gif images onto static image; undesired results

Post by Don »

To avoid the possibility of duplicating one or more frames or get blank when adding frames, lets go with 28 frames then.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Animated gif images onto static image; undesired results

Post by fmw42 »

If you are going to loop indefinitely, then you would be best with snibgo's suggestion of integer multiple of your frames such that they produce the same counts.

Also you may have trouble if the delays are not the same in the two animations. See my link above to Anthony's notes about merging
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Animated gif images onto static image; undesired results

Post by snibgo »

I find long commands easier to understand when split into lines. Bash syntax:

Code: Select all

convert \
  toes.png \
  null: \
  \( downArrow.gif -coalesce -delete 0-7 \) \
  -gravity Northwest -compose over -layers composite \
  null: \
  \( leftArrow.gif -coalesce \) \
  -gravity SouthEast -compose over -layers composite \
  -layers Optimize \
  x.gif
You can see I have removed the first 8 frames from down arrow.

Another possibility:

Code: Select all

convert \
  toes.png \
  null: \
  \( downArrow.gif -coalesce -delete 0,2,4,6,8,10,12,14 +write info: \) \
  -gravity Northwest -compose over -layers composite \
  null: \
  \( leftArrow.gif -coalesce +write info: \) \
  -gravity SouthEast -compose over -layers composite \
  -layers Optimize \
  x2.gif
This removes every other frame from down arrow until 8 frames are removed. The result is smoother than the previous one.
snibgo's IM pages: im.snibgo.com
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Animated gif images onto static image; undesired results

Post by Don »

Thank you to both especially snibgo as I'll look into the above code. Much appreciation.
Post Reply