Page 1 of 2

merging looped animations serially

Posted: 2011-06-27T15:13:33-07:00
by viper-2
I'm trying to merge three looped animations as a single animated .gif. I thought the solution should be really simple, but I've noted Anthony's warning "ut it may not be quite as easy as it looks" at <http://www.imagemagick.org/Usage/anim_mods/#merging>;-)

I converted 2 files, iris0.png and iris1.png, resizing each with resolutions 900x675, 720x540, 576x432. I then made 3 animations, each corresponding to 1 resolution:

convert -delay 30 iris0-900.png iris1-900.png -loop 6 iris-900.gif
convert -delay 30 iris0-720.png iris1-720.png -loop 6 iris-720.gif
convert -delay 30 iris0-576.png iris1-576.png -loop 6 iris-576.gif

I then merged the animations:

convert iris-900.gif iris-720.gif iris576.gif -loop 1 iris.gif

Instead of the resulting animation looping once, playing each component gif in sequence, iris.gif loops 6 times playing the 2 files at each resolution only once in each cycle.

I've tried using :null to mark the end of each sequence to no avail (see <http://www.imagemagick.org/Usage/anim_mods/#composite>) and coalesce doesn't seem to help.

I've uploaded the animations in the folder "splash-test" at the bottom of this page
<http://www.codeartnow.com/code/download ... -2-preview>

Have I overlooked something simple? Thanks for your patience.;-)

agt

Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: merging looped animations serially

Posted: 2011-06-27T16:53:54-07:00
by fmw42
I am not an expert on animation. But ...

I believe the issue may be that there are only two files in each animation. you need to duplicate the image 6 times to get the animation to play 6 times before going to the next resolution. Just because you are telling each one to loop 6 times means nothing as I expect the merge will ignore the loop for each one.

You may also have trouble with the disposal, so you should read about that as the animations are not the same size. see http://www.imagemagick.org/Usage/anim_basics/#dispose.

see http://www.imagemagick.org/Usage/basics/#duplicate but you will need a recent version of IM to use it as it was added in IM 6.6.8-7.


Also I don't see you link to "splash-test" folder

Re: merging looped animations serially

Posted: 2011-06-27T17:26:27-07:00
by viper-2
fmw42 wrote:I am not an expert on animation. But ...

I believe the issue may be that there are only two files in each animation. you need to duplicate the image 6 times to get the animation to play 6 times before going to the next resolution. Just because you are telling each one to loop 6 times means nothing as I expect the merge will ignore the loop for each one.

You may also have trouble with the disposal, so you should read about that as the animations are not the same size. see http://www.imagemagick.org/Usage/anim_basics/#dispose.

see http://www.imagemagick.org/Usage/basics/#duplicate but you will need a recent version of IM to use it as it was added in IM 6.6.8-7.


Also I don't see you link to "splash-test" folder
I may be thinking of using loop more in terms of a nested programming construct. I have IM 6.7.0-8; I'll have a look at the #duplicate page and report back tomorrow.

codeartnow.com is a google site. There's no link to the folder splash-test in the filing cabinet, but there are links to each file in the folder, just go to the bottom of the page <http://www.codeartnow.com/code/download ... -2-preview>
and you'll see the folder.

This, e.g., will take you to the final animation iris.gif:
<http://www.codeartnow.com/code/download ... ects=0&d=1>

Re: merging looped animations serially

Posted: 2011-06-27T17:53:21-07:00
by fmw42
try this


convert -delay 20 -dispose previous \
\( -delay 20 iris-900.gif -duplicate 6,0--1 \) \
\( -delay 20 iris-720.gif -duplicate 6,0--1 \) \
\( -delay 20 iris-576.gif -duplicate 6,0--1 \) \
-loop 1 iris.gif

or this


convert -delay 20 -dispose previous \
\( -delay 20 iris-900.gif -duplicate 6,0--1 -bordercolor white -border 1 \) \
\( -delay 20 iris-720.gif -duplicate 6,0--1 -background white -gravity center -extent 902x677 \) \
\( -delay 20 iris-576.gif -duplicate 6,0--1 -background white -gravity center -extent 902x677 \) \
-loop 1 iris2.gif

Re: merging looped animations serially

Posted: 2011-06-27T20:05:07-07:00
by viper-2
fmw42,

Thank you, the sequence is now correct - but the file takes 6 minutes to load, and another 3 minutes to read all 42 files (the title bar counts 42)!!

I've only tried the first solution, but this wouldn't work for a splash screen. Disposal gives the same chequerboard results as before. I'm going to forget about disposal for now and concentrate on the sequencing for a more memory efficient solution. Will post back tomorrow after reading about the -duplicate switch.

agt

Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: merging looped animations serially

Posted: 2011-06-27T20:10:28-07:00
by fmw42
try the second one, it is rather slow, but the disposal works out so that the background is white and does not leave the previous image behind. (at least for me). I seem to recall your earlier message where you were getting the background from the previous image and could not avoid that. The white border is what is needed to avoid that along with -dispose previous, even though it worked for me. Seems like you are still having that problem with your version of IM/platform. The -gravity center -extent allows each size to be centered rather than put in the upper left corner, which to me looks strange.

Re: merging looped animations serially

Posted: 2011-06-27T20:12:10-07:00
by anthony
the -loop N is just a setting that is added to a GIF animation. It tells the animation program (web browser or animate) to loop N times than stop.

However there is no control in a GIF animation beyond a simple (loop everythng N times). You can not loop 5 frames 6 times then the next 5 frames 6 times. You can only loop all 10 frames 6 times.

You can think of loop, as taking a film strip (there is only one strip) and splicing the begining to the end. and runing round the loop N times. That is it.

As Fred pointed out the only way to say loop a sub-set of frames is to duplicate those frames. A bit like making copies of a film strip and splicing them to form a longer film strip.

As for the positioning... You can simple add an relative offset to the later sequences. that is what the offsets are for!
See http://www.imagemagick.org/Usage/anim_m ... e_relative

Of just create a coalesce (full frame film strip like) sequence and use -layers optimize to remove any unnessary image data and set the right disposal method.

Re: merging looped animations serially

Posted: 2011-06-27T20:28:05-07:00
by fmw42
As for the positioning... You can simple add an relative offset to the later sequences. that is what the offsets are for!
See http://www.imagemagick.org/Usage/anim_m ... e_relative
Anthony,

Good information about repositioning that I did not know. Learn something new today.

However, for IM 7 it might be nice to allow the use of gravity so that each frame might be centered if desired when they are different sizes.

Fred

Re: merging looped animations serially

Posted: 2011-06-28T07:39:37-07:00
by viper-2
I agree that positioning the image from the top left hand corner is strange.This was the reason for using backdrop in my very first post on this problem. The problem I've been having is that there is unexpected behaviour (cropping etc) whenever the image size is larger than the screen resolution.

The use of duplicate at all levels creates an unwieldy animation that's far too memory intensive for a splash screen. I'll have to simplify the animation to minimise the load+play time. I'm about to try a few things suggested by fmw42's solutions, and will post back later.

BTW Fmw42, I came across the amazing Fred's ImageMagickScripts ages ago, and had no idea that fmw42 was Fred!

agt

Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: merging looped animations serially

Posted: 2011-06-28T10:28:53-07:00
by fmw42
see -page and -repage for positioning at http://www.imagemagick.org/Usage/anim_basics/

also see frame optimizations to make your animation smaller at http://www.imagemagick.org/Usage/anim_opt/

Re: merging looped animations serially

Posted: 2011-06-28T13:16:31-07:00
by viper-2
fmw42 wrote:see -page and -repage for positioning at http://www.imagemagick.org/Usage/anim_basics/

also see frame optimizations to make your animation smaller at http://www.imagemagick.org/Usage/anim_opt/
Yes, I saw those pages a few days ago. I'll be spending sometime there as well as with Fred's ImageMagickScripts ( :))to learn more about IM.

I've uploaded iris3.gif to the same webpage:
<http://www.codeartnow.com/code/download ... -2-preview>

This simplifies the animation so I don't use too many duplicates; loading is dramatically faster:

convert \
\( -delay 300 iris0-900.png iris1-720.png \) \
\( -delay 30 iris0-576.png iris1-576.png -duplicate 2,0--1 \) \
-loop 1 iris3.gif

and I play iris3.gif using:

:~$ animate -title "C-Graph" -pause 3 iris3.gif

Your code for iris2.gif worked nicley with the -gravity center setting. I can see how you were trying to use the white background to compensate for my transparency issues and the chequered pattern. I prefer the stacked images to the white background, though. I'll experiment how to use -gravity center without extent. Right now, -gravity center has no effect when inserted in the code above.

agt

Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: merging looped animations serially

Posted: 2011-06-28T15:06:39-07:00
by fmw42
-gravity does not affect animations. that is why you need to use -page or -repage. it worked for me because I filled out each image to the same size using -extent which is sensitive to -gravity

Re: merging looped animations serially

Posted: 2011-06-28T17:50:32-07:00
by viper-2
fmw42 wrote:-gravity does not affect animations. that is why you need to use -page or -repage. it worked for me because I filled out each image to the same size using -extent which is sensitive to -gravity
Fred,

I've discovered that the -gravity switch is relevant only to options that use -geometry. C-Graph users will have different screen sizes and resolutions, so page and repage will be less useful in arriving at a general solution. I've decided to call it a day with the splash image. It's time to get some much needed rest.

Many thanks to you and Anthony for pointing out:

a) that one uses animate to play animations and not display,
b) that -duplicate and not -loop is the option needed to replay the images at each resolution.

Without your help, I could have spent ages experimenting. So to express my appreciation, I'll be mentioning you in the THANKS file for C-Graph, and I'll let you know when the package is released.

Kudos to ImageMagick, and Happy hacking!

agt

Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: merging looped animations serially

Posted: 2011-06-28T18:36:03-07:00
by fmw42
That was why I suggested to Anthony above that

"However, for IM 7 it might be nice to allow the use of gravity so that each frame might be centered if desired when they are different sizes."

But I know that -gravity and -page do not mix. So it would be nice if there was some way to set the virtual canvas in some special way so that something like -page center would be possible. It is useful not only for animations but also for many -layer methods. Only -composite allows -gravity and -geometry at the moment.

Re: merging looped animations serially

Posted: 2011-06-28T19:20:59-07:00
by anthony
viper-2 wrote:The use of duplicate at all levels creates an unwieldy animation that's far too memory intensive for a splash screen. I'll have to simplify the animation to minimise the load+play time. I'm about to try a few things suggested by fmw42's solutions, and will post back later.
How much control do you have over the drop screen? Can you modify the program, or monitor and change things when a specific animation ends?

For example. As a proof of concept I created a script that fades from one image to a another image.
http://www.imagemagick.org/Usage/script ... show_morph

The sequence is not fixed. The program selects the new image to display, creates a 'fade crossover' animation, then asks 'animate' to run that animation once. When the animation is complete it then replaces that animation with a new animation of just the new static image, until it is time to select the next image to fade to.

Essentually it is a wrapper that monitors and controls a "animate" sub-process. A technique known as 'co-processing'.