Hi,
I have been searching around for a while to an answer to this question.
I am trying to merge an animated gif + animated gif = animated gif.
Better I show you than try to describe it:
This is the image created:
This is the ski image:
This is the sonic image:
What I want to know is how to add a delay (for example, show number 1 for 3
seconds and number 2 for 5 seconds.. or whatever I pick) between the two
frames as well as have them animated they way they are in the example...
Thanks for any suggestions
Animated Gif
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Animated Gif
I am no expert at merging animations, but the timing of the two animation (delay between frames may not be the same), which is difficult to work around. But try using -coalesce
See http://www.imagemagick.org/Usage/anim_mods/
try
convert \( animation1.gif -coalesce \) \( animation2.gif -coalesce \) finalanimation.gif
See
http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_mods/
See http://www.imagemagick.org/Usage/anim_mods/
try
convert \( animation1.gif -coalesce \) \( animation2.gif -coalesce \) finalanimation.gif
See
http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_mods/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Animated Gif
You can add a pause between the animations by adjusting the delay of the final frame of the first coalesced animation.
This uses information found in IM Examples, Animation Basics, and more specifically Animation Modification, Frame by Frame modification.
this for example extracts the last frame of the first animation,
and changes its delay to 5 seconds, before appending (time wise) the second animation. That last frame is also adjusted the same way, before the whole sequence loops.
If you want to just display the animation (animating) for 5 seconds, you will have to loop the animation yourself over the whole time period. For that you may like to examine the total loop time for each animation using something like the script "gif2anim" which is used within IM Examples, to figure out how many time you want to loop, either in whole or partial loops. See Animation Basics, Sequence Information for more infromation on this script I developed.
You will need to add a '-t' option to the script to include timing comments in the output file. From that script I see the skier is 160 centi-seconds before looping, while sonic is only 50 centi-seconds (1/2 second) before looping. As such you will need more loops of sonic in your final animation.
On the other hand overlaying two animations, is tricky. And gets worse if the timing sequence are not the same (asynchronously time merger). These are also discussed in IM Examples, Animation modifications, at the bottom of the page. however, no final solution has been compiled into the IM core library (yet). Programmers wanted
This uses information found in IM Examples, Animation Basics, and more specifically Animation Modification, Frame by Frame modification.
this for example extracts the last frame of the first animation,
and changes its delay to 5 seconds, before appending (time wise) the second animation. That last frame is also adjusted the same way, before the whole sequence loops.
Code: Select all
convert animation1.gif -coalesce \
\( +clone -set delay 5/1 \) +swap +delete \
\( animation2.gif -coalesce \) \
\( +clone -set delay 5/1 \) +swap +delete \
-layers optimize final_animation.gif
You will need to add a '-t' option to the script to include timing comments in the output file. From that script I see the skier is 160 centi-seconds before looping, while sonic is only 50 centi-seconds (1/2 second) before looping. As such you will need more loops of sonic in your final animation.
On the other hand overlaying two animations, is tricky. And gets worse if the timing sequence are not the same (asynchronously time merger). These are also discussed in IM Examples, Animation modifications, at the bottom of the page. however, no final solution has been compiled into the IM core library (yet). Programmers wanted
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Animated Gif
Thanks for your help Anothy.If you want to just display the animation (animating) for 5 seconds, you will have to loop the animation yourself over the whole time period. For that you may like to examine the total loop time for each animation using something like the script "gif2anim" which is used within IM Examples, to figure out how many time you want to loop, either in whole or partial loops. See Animation Basics, Sequence Information for more infromation on this script I developed.
Basically converting the image into itself a few times and then merging it into another (the sonic)
makes the original image play for however long it should before moving onto the next.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Animated Gif
Correct.
Figureing how many times to loop for a fixed time period is the tricky part, as you need to count up all the delays to figure this out.
Note taht some animations can be very long, and many not fit into a fixed time period very well, requiring you to cut them short at the appropriate moment. It is all a matter of how far you want to take it.
If you come up with anything that may be of interest, like a script that can do this, or some other technique, then please share.
Figureing how many times to loop for a fixed time period is the tricky part, as you need to count up all the delays to figure this out.
Note taht some animations can be very long, and many not fit into a fixed time period very well, requiring you to cut them short at the appropriate moment. It is all a matter of how far you want to take it.
If you come up with anything that may be of interest, like a script that can do this, or some other technique, then please share.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/