`6/8/22, 12:32 PM
`The Wayback Machine - https://web.archive.org/web/20120310193613/http://www.imagemagick.org:80/Usage/anim_b…
`
`ImageMagick v6 Examples --
`
` Animation Basics
`
`Index
` ImageMagick Examples Preface and Index
` GIF Animations and Animation Meta-data
` Frame Disposal Methods
`
`Dispose None - overlay each frame in sequence
`Dispose Previous - preserve background canvas
`Dispose Background - clear to background
`
` Studying Animations
`
`Identify - information about an animation
`Adjoin - splitting into individual frame images
`Coalesce - fill out frames completely
`Frame Montage - the "gif_anim_montage" script
`List Information - rebuild an existing animation
`Disposal Images - the GIF dispose form of the frames
`Deconstruct - report areas of frame differences
`Frame Comparisons - more detailed frame differences
`
`Compare_Any, Compare_Clear, Compare_Overlay
`
` Types of Animations
`
`Coalesced Animations
`Overlay Animations
`Cleared Frame Animations
`Mixed Disposal Animations
`
` The End of the Loop - when an animation stops running
` Zero Delay Intermediate Frames
`
`These examples continue the previous example page on Layers of Multiple Images but instead of layering multiple images
`on top of each other to produce a single image, here we display each image for a short period of time so as to produce an
`animation of images.
`
`The following section provides a basic understanding of the complexities of animations and specifically GIF animations. It
`looks at the basic methods used to generate animations, and how you can study existing animations to get an
`understanding of how they work.
`
`This is recommended reading before going further in any of the later animation sections.
`
`GIF Animations and Animation Meta-data
`
`The default way ImageMagick handles the output of a image list is to generate a multi-page image. For the GIF image
`format, however, this takes the special form of a 'GIF animation'.
`
` convert -delay 100 -size 100x100 xc:SkyBlue \
` -page +5+10 balloon.gif -page +35+30 medical.gif \
` -page +62+50 present.gif -page +10+55 shading.gif \
` -loop 0 animation.gif
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`1/21
`
`Lightricks Ltd., EX1007, Page 1 of 21
`
`
`
`6/8/22, 12:32 PM
`
`Animation Basics -- IM v6 Examples
`
`Here is a more advanced 'sparkle' example that uses a shell script "star_field". This script was developed from my
`experiments in generating random star fields.
`
` star_field 70x46 stars1.gif
` star_field 70x46 stars2.gif
` star_field 70x46 stars3.gif
` convert rose: -compose Screen \
` \( -clone 0 stars1.gif -composite \) \
` \( -clone 0 stars2.gif -composite \) \
` \( -clone 0 stars3.gif -composite \) \
` -delete 0 -set delay 25 -layers Optimize rose_sparkle.gif
` rm stars[123].gif
`
`Basically three random star fields are generated, at the right size, then overlaid onto our image, the IM built-in "rose:",
`using a 'Screen' alpha composition to brighten the image with the given star patterns. The whole thing is then run though
`the IM general GIF animation optimizer.
`
`The above may seem complex as it is using some advanced IM features I have yet to introduce, but the result is a
`relatively simple, but well optimized three frame animation.
`
`You can also look at some of the more complex animations that were created using simple shell scripts for Distortion
`Animations.
`
`There are a few extra IM settings which were created specifically for use in GIF animations, and knowing about these is
`the first step into the world of GIF animations...
`
`-dispose {method}
`What the following images should do with the previous results of the GIF animation. Valid
`options are 'Undefined', 'None', 'Previous', and 'Background. (See below for explanation of the
`settings)
`
`-loop {number} Number of times the GIF animation is to cycle though the image sequence before stopping.
`It is an output 'image write' setting, so can be set anywhere on the command line, though
`only the last such setting will be used.
`
`Usually this set by default, to zero (infinite loop), however if any image read in has a
`different value, then this setting will be set to that images value. As such I recommend that
`you always set "-loop" when creating a GIF animation, after all the images has been read in.
`
`For more information see The End of the Loop below.
`
`-delay {time}
`
`
`Set the time delay (in 1/100th of a second) to pause after drawing the images that are read in
`or created after this setting has been defined.
`
`You can specify a different scale for the time delay by specifying a 'x' scaling (giving in ticks
`per second). For example '10x1' is 10, 1 second ticks, while '10x100' is 10, one hundredth of a
`second ticks.
`
`Basically the 'x' is equivalent to a fraction '/' sign. For example if you specify '1x160' will set
`a delay that is appropriate for 160 frames per second.
`
`GIF animation delays must be specified in hundredths of a second for correct working, which is
`why that is the default time unit. The 'x' factor is used more for generating other more movie
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`2/21
`
`Page 2 of 21
`
`
`
`6/8/22, 12:32 PM
`
`Animation Basics -- IM v6 Examples
`like formats, such a MNG's, and AVI's.
`
`-set dispose {method}
`
`-set delay {time}
`While the previous option settings will set image attributes on newly created, or image that
`are read in, after that option is given, the "-set" option is an operator, that will allow you set
`image attributes on all images that have already in the current image sequence. This allows
`you to change the setting over a whole animation, or just a single frame, after the images
`have been loaded or modified.
`
`-page {w}x{h}+{x}+{y}
`This lets you set the offset position of the image about to be read in. As this is a setting
`option, it only applies the geometry you give to images that follow the setting. It does not
`effect images already read into memory.
`
`If not given, or turned off using "+page" the offset for the image read will be preserved. If the
`image does not have an offset it will be positioned at '+0+0' or the top left corner of the
`working canvas or 'page'.
`
`It can also be used to define a larger working canvas, by specifying a width 'x' height. Only
`the width and height page setting of the first image in the sequence will be used to set the
`overall GIF animation canvas size, all other page size settings will be ignored when the
`animation is finally written. When a GIF animation is read in the canvas size is set on all the
`frames in the animation.
`
`MNG animations can save frame offsets, but does not save canvas sizes. The size of the first
`image defines the canvas size of the whole animation.
`
`The GIF image format can not specify a negative offset for images on a canvas. If you try to
`use a negative offset IM will reset it to zero when that image (or animation frame) is written to
`a GIF file.
`
`Positive offsets larger than the image canvas are quite acceptable but may result in the image
`not appearing in the canvas drawing area when displayed. How a GIF animation display
`program handles this is undefined. Caution is advised.
`
`-repage {w}x{h}+{x}+{y}
`This is exactly like "-page" except that it is an image operator instead of a setting. That
`means you can use this to change or reset the 'page geometry' of an image or animation
`frame that has already being read into memory.
`
`The simpler "+repage" form, just resets the 'page geometry' of all images to the actual image
`in each frame in the current image sequence to a zero offset, and the images actual size. This
`operation is vital when you are extracting the individual frames from an animation, (See the
`Adjoin Examples below).
`
`However "+repage" will destroy a lot of positioning information stored in each image, as
`such you should also probably extract this information into a separate file for later re-use.
`See Animation List Information below.
`
`Important Point
`
`DO NOT save the intermediate, animations which you are not finished processing, directly to GIF. You can use the IM
`internal format MIFF, as a temporary file format, if you want to work on an animation in series of separate processing
`steps.
`
`I repeat...
`
`Do not use GIF as a intermediate file format, use MIFF instead
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`3/21
`
`Page 3 of 21
`
`
`
`Animation Basics -- IM v6 Examples
`6/8/22, 12:32 PM
`If you made the big mistake of saving to GIF you would have just made the resulting animation worse, as IM would have
`now performed an automatic Color Quantization, to reduce the number of colors present. Not only that but it did so on
`each frame completely independently to every other frame, making any further processing, particularly any GIF
`optimizations just that much harder.
`
`Solving this is a complex, multi-level problem, which is looked at in the next section Animation Optimization.
`
`Frame Disposal Methods
`
`The first thing people creating GIF animation have trouble with is the "-dispose" setting. This is not surprising as it is a
`complex setting. Worse still a lot of animation programs, including many web browsers, don't always handle the GIF
`disposal meta-data setting correctly. However using the right disposal can make a big difference to how well your
`animation works and optimizes.
`
`The first thing to remember in ImageMagick is that almost all the special animation options, are settings for image
`reading. That is they are applied to images that are read in, after, the setting has been given. The "-loop" setting is the only
`one typically used after the animation has been completed, just before the the animation is saved.
`
`The basic task of the "-dispose" defines how an image is to be removed, after it has been displayed for its "-delay" time
`period. That is, you need to give an image's "-dispose" and "-delay" settings before reading the image for that frame. But
`the action is applied after that image is displayed. This is a little counter intuitive but does make sense in the way IM
`operates on images.
`
`If you remember this, you should have no problems.
`
`The 'plus' forms of these options, like most other settings in IM stops the setting being applied to any images being read in.
`That means if you don't specify a setting, the frame image will continue to use the setting that was read in with the image
`(if any).
`
`This can be important later when you want to read in a GIF animation for further processing. Or when merging one GIF
`animation into another (the most difficult animation technique).
`Dispose None - each frame overlaid in sequence
`
`The default "-dispose" setting for GIF animations is 'Undefined' which most animation programs treats the same as a 'None'
`disposal setting. Basically this tells the computer to just leave whatever is overlaid by this specific frame. Or more
`precisely, 'do nothing'.
`
`However please note that the whole canvas is always cleared at the end of the animation sequence, before it loops and
`repeats.
`
`Here for example is a standard 'None dispose' animation...
`
` convert -delay 100 -dispose None \
` -page 100x100+5+10 balloon.gif \
` -page +35+30 medical.gif \
` -page +62+50 present.gif \
` -page +10+55 shading.gif \
` -loop 0 anim_none.gif
`
`This disposal technique is ideal for animations which involve no form of transparency, such as animations drawn on a
`solid, or patterned background.
`
` convert -dispose none -delay 100 \
` -size 100x100 xc:SkyBlue +antialias \
` -fill DodgerBlue -draw 'circle 50,50 15,25' \
` -page +5+10 balloon.gif \
` -page +35+30 medical.gif \
` -page +62+50 present.gif \
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`4/21
`
`Page 4 of 21
`
`
`
`6/8/22, 12:32 PM
` -page +10+55 shading.gif \
` -loop 0 canvas_none.gif
`
`Animation Basics -- IM v6 Examples
`
`Note that this technique can only add visible colors to an animation. It can never actually make any part of an animation
`transparent again. (See Overlay Animations below).
`
`To also handle transparency need to use one of the other sorts of disposal methods.
`Dispose Previous - preserve background canvas
`
`The 'Previous' disposal method is relatively simple. When the current image is finished, return the canvas to what it looked
`like before the image was overlaid. If the previous frame image also used a 'Previous' disposal method, then the result will
`be that same as what it was before that frame.. etc.. etc.. etc...
`
`For example in this animation each of the later frames will return to the very first frame of the image, which has a 'None
`disposal setting, before overlaying the image associated with that frame.
`
`The result is a background canvas that has just each frame image overlaid for just the duration of that image...
`
` convert -dispose none -delay 0 \
` -size 100x100 xc:SkyBlue +antialias \
` -fill DodgerBlue -draw 'circle 50,50 15,25' \
` -dispose previous -delay 100 \
` -page +5+10 balloon.gif \
` -page +35+30 medical.gif \
` -page +62+50 present.gif \
` -page +10+55 shading.gif \
` -loop 0 canvas_prev.gif
`
`Note the "-dispose" method 'None' used for the first image. This is important, otherwise the 'previous' frame will go all the
`way back to the original empty canvas that was present before the first frame.
`
`Also note that I used a "-delay" of '0' in the above animation. This says not to wait before overlaying the first frame onto
`this 'background canvas'. Without it you will see a short delay, showing just the canvas image with nothing on top of it.
`
`Of course I need to still set a longer "-delay" for the later images, or they will appear and disappear in the wink of an eye,
`and incidentally use up a lot of the viewers CPU cycles.
`
`The use of the 'Previous' disposal method can be prone to a slight flickering, or pause in some web browsers, especially on
`slower machines. Though that is quite rarely seen these days, the flicker itself is still present, and something I consider to
`be a bug. See Zero Delay Frames below for more specifics.
`
`Few animations make use of a dispose previous style of animation, the reason is that it is very difficult for computers to
`optimise. The problem is just what frame should the computer pick to become the background image? Simple for us
`humans to figure out the best image to use, but difficult for a computer decide. The best background image to use in an
`animation may not even be meant to be displayed, such as in the current example, and as such may not exist in a un-
`optimized version of that animation.
`Dispose Background - clear to background
`
`While the first two "-dispose" methods are relatively simple, the 'Background' is probably the hardest to understand.
`
`When the time delay is finished for a particular frame, the area that was overlaid by that frame is cleared. Not the whole
`canvas, just the area that was overlaid. Once that is done then the resulting canvas is what is passed to the next frame of
`the animation, to be overlaid by that frames image.
`
`Here for example we just replace each frame with the next frame.
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`5/21
`
`Page 5 of 21
`
`
`
`6/8/22, 12:32 PM
`
`Animation Basics -- IM v6 Examples
`
` convert -delay 100 -dispose Background \
` -page 100x100+5+10 balloon.gif \
` -page +35+30 medical.gif \
` -page +62+50 present.gif \
` -page +10+55 shading.gif \
` -loop 0 anim_bgnd.gif
`
`So you can see exactly what is going on, lets add an initial canvas image to the animation, so you can see how a
`'Background' actually 'disposes' that frame from the animation display.
`
` convert -delay 100 -dispose none \
` -size 100x100 xc:SkyBlue +antialias \
` -fill DodgerBlue -draw 'circle 50,50 15,25' \
` -dispose background \
` -page +5+10 balloon.gif \
` -page +35+30 medical.gif \
` -page +62+50 present.gif \
` -page +10+55 shading.gif \
` -loop 0 canvas_bgnd.gif
`
`As you can see as each overlaid frame is disposed of, that frames area is cleared to transparency, before the next image is
`overlaid. This is the importance of this GIF disposal method as it is the only way GIF animations can clear any pixel
`regardless of an animations frame history.
`
`The only other way to clear pixels is to use 'Previous' to go back to a frame in which those pixels were clear. But that
`relies on knowing the history of the animation sequence which makes it much more difficult for computers to optimize.
`
`There is some thinking that rather than clearing the overlaid area to the transparent color, this disposal should clear it to the
`'background' color meta-data setting stored in the GIF animation. In fact the old "Netscape" browser (version 2 and 3), did
`exactly that. But then it also failed to implement the 'Previous' dispose method correctly.
`
`On the other hand the initial canvas should also be set from the formats 'background' color too, and that is also not done.
`However all modern web browsers clear just the area that was last overlaid to transparency, as such this is now accepted
`practice, and what IM now follows.
`
`Before IM version 6.2.6-1, the IM "-coalesce" and "-deconstruct" operations did not handle animations that used 'Background'
`disposal to make pixels transparent, as per all the major web browsers. See Animation Bugs for examples and details.
`
`These functions however did work fine when no pixel clearing was applied or intended. This has now been fixed for "-coalesce"
`and the "-layers OptimizeFrame' method was created to replace the use of "-deconstruct" as a GIF animation frame optimizing
`function.
`
`Studying Animations
`
`Before we can continue with the basics of GIF animation, their types, optimizations, and handling techniques, we need
`some techniques for studying existing animations.
`Identify - information about and animation
`
`Now an animation consists of a lot of information packed into each individual frame. You can see some of this information
`using the default IM "identify" command.
`
` identify canvas_prev.gif
`
`If you did not see output like the above your IM is a little old, and you really should upgrade your installed version of
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`6/21
`
`Page 6 of 21
`
`
`
`6/8/22, 12:32 PM
`
`Animation Basics -- IM v6 Examples
`ImageMagick, to the latest version. If you don't you will be missing out on a lot of the new advances in IM's handling and
`control of GIF animations.
`
`As you can see the actual image saved for the second and later frames is only 32x32 pixels, but all the frames sits on a
`100x100 pixel 'virtual canvas' with a 'virtual offset' on that larger canvas.
`
`To see more of the various bits of meta-data that is present you need to use some of the more specialzed percent Escape
`Formats to get IM to output it.
`
` identify -format "%f canvas=%Wx%H size=%wx%h offset=%X%Y %D %Tcs\n" \
` canvas_prev.gif
`
`Which clearly shows not only the canvas size, image size and offset, but also the disposal and time delays used for each
`individual frame. Note how the first frame has the different disposal and time delay that was needed for proper use of the
`later 'Previous' disposal method.
`Adjoin - splitting an animation into frames
`
`Now as you saw above, ImageMagick will by default try to save multiple images into one file if that file format allows it.
`However as discussed in Writing a Multi-Image List IM will let you use the "+adjoin" setting to tell it to save each image
`to disk as a separate individual image.
`
`For example, here we read in one of the GIF animations and output the individual frame images in the animation
`sequence.
`
` convert canvas_prev.gif -scene 1 +adjoin frame_%03d.gif
`
`
`
`
`
`
`
`
`
`If you were to examine the actual images above you will find that although most web browsers show a larger 100x100
`area, on which each sub-frame appears. In fact most of the actual images show are really only just 32x32 pixels, just as
`show in the previous 'identify' commands above.
`
`That is most of the area is just a canvas on which nothing is drawn, known as the images 'page geometry' or 'virtual
`canvas'. The first image of the animation defines that larger 'canvas' and every other frame defines an 'offset' position on
`this larger canvas.
`
`This extra information is preserved in the frames that was saved by the "+adjoin" setting. As as such you can easilly re-
`build the GIF animation. Not only is the page information preserved in each separate frame image, but also any delay,
`looping and GIF dispose settings, is also preserved.
`
`This means that to rebuild the animation you only need to read all the images in.
`
` convert frame_???.gif anim_rebuilt.gif
`
`Sometimes however you don't want to preserve this page geometry information. For example if you want to use the
`individual frames for other projects. You can reset the page size and offset using the "+repage" option, to remove the
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`7/21
`
`Page 7 of 21
`
`
`
`Animation Basics -- IM v6 Examples
`6/8/22, 12:32 PM
`'virtual canvas' information, leaving just the actual image.
`
`Normally when extracting animation sub-images you also generally reset the images delay and dispose settings too to
`ensure they don't interfer with the editing and display.
`
`For example here I remove the unwanted virtual canvas and offset and reset the timing delays and disposals.
`
` convert canvas_prev.gif +repage -set delay 0 -set dispose None \
` +adjoin repage_%03d.gif
`
`
`
`
`
`
`
`
`
`Of course if you junk that meta-data, you need some way of recording and editing that data. See Animation List
`Information (below) for a script that extracts both the sub-images and saves the animation meta-data, in a form that can be
`used to re-build the animation.
`Coalesce - fill out frames completely
`
`Viewing an animation in the form of the sub-frames, however is usually not very useful, in a typical animation.
`
`For one thing, a highly optimized animation can consist of lots of very small parts, without any visual indication of how
`they fit together. It can also have a lot of other 'noise' that was added for Compression Optimization to reduce the overall
`file size of the animation.
`
`For example, it is very difficult to figure out what this animation actually did, just by looking at the individual sub-frames
`of the animation.
`
` convert script_k.gif +repage +adjoin script_k_%02d.gif
`
`
`
`
`
`
`
`
`
`
`
`
`The "-coalesce" operation basically converts an image into exactly what the animation should look like after the previous
`frame has been correctly disposed, and the next sub-frame overlaid.
`
`That is instead of an animation sequence where each frame only represents the overlaid changes to the previous 'disposed'
`frame. This operator creates a complete view of the animation at each point, a bit like a true film strip, rather than an
`animation sequence. Such a sequence, known as a Coalesced Animation is much easier to study, edit, modify and re-
`optimize.
`
`Here for example will generate a montage of the same 'confusing' animation sequence I showed above, but this time we'll
`"-coalesce" the sequences, so you can see what is really happening.
`
` montage script_k.gif -coalesce \
` -tile x1 -frame 4 -geometry '+2+2' \
` -background none -bordercolor none coalesce_k_montage.gif
`
`As you can see the result is like a film strip of the animation, allowing you to clearly see how the previous pieces fit
`together to form a hand drawn letter 'K'.
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`8/21
`
`Page 8 of 21
`
`
`
`Animation Basics -- IM v6 Examples
`6/8/22, 12:32 PM
`As of IM version 6.2.6, the "montage" command understood the use of "-coalesce", allowing you to create 'film strip' like
`image of the animation frames, exactly as shown above. This version also contained fixed for coalesce, and nay GIF
`animation work should be at least this version (or better still the latest version).
`
`An even better montage technique for examining animations is given in the next example section.
`
`The "-dispose" setting of a coalesced image sequence is actually irrelevant, in a Coalesced Animation. However for users
`piece of mind the "-coalesce" operator will set the "-dispose" setting of each frame to either 'None' or 'Background' as
`appropriate, so that the coalesced image sequence will continue to animate correctly (as shown above).
`
`A frame with a 'Background' disposal means the next frame needed to clear at least one or more pixels, to be displayed correctly.
`
`As such animations in which "-coalesce" added a 'Background' dispose, means that the animation can not be saved as a simple
`Overlay Animation (see below).
`
`Technically, you can set all dispose settings of a coalesced image sequence to either 'Background' or 'Previous' to generate a
`Cleared Frame Animation (see below). Though not all animations will optimize well in that form.
`
`Their are also some non-animation uses of the "-coalesce" operator. See Coalesce, and Progressive Flattening examples of
`these uses.
`
`Animation Frame Montage - the "gif_anim_montage" script
`
`While "+adjoin" operator will let you extract the actual images from an animation and "-coalesce" will let you see the
`resulting frames of the animation, both methods leave out a lot of information about the animation.
`
`By using some very careful manipulation of the animation images, you can display the frames so as to show not only the
`actual frames, but also the placement of those frames on the larger canvas. Here is one such method of displaying an
`animation.
`
` convert -dispose Background script_k.gif -matte \
` -compose Copy -bordercolor black -border 1x1 -compose Over \
` -coalesce -bordercolor none -frame 4x4+2+2 \
` -bordercolor none -border 2x2 +append script_k_parts.gif
`
`Here you can clearly see how the animation works. Each sub-frame image is positioned so as to add to all the previous
`overlays. The result is a slowly growing picture. Each frame is also a lot smaller than the 'virtual canvas' on which it is
`positioned.
`
`I use this display technique a lot during the development and debugging of GIF animations, as such I converted it into a
`shell script "gif_anim_montage", and expanded it to also list some of the details above each frame in the animation.
`
` gif_anim_montage script_k.gif script_k_frames.gif
`
`Note the variations in the timings used in various frames, to pause as if the pen is being lifted from the page and
`repositioned. Animations with variable timing can be some of the most interesting, but also more difficult to handle, as
`you will see in later IM Example pages.
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`9/21
`
`Page 9 of 21
`
`
`
`Animation Basics -- IM v6 Examples
`6/8/22, 12:32 PM
`The "gif_anim_montage" script also the special option '-u' which will also underlay a semi-transparent copy of the
`coalesced animation. This lets you see how the new sub-frames modifies the displayed animation.
`
` gif_anim_montage -u script_k.gif script_k_frames.png
`
`Of course this has semi-transparent pixels so a 'PNG' image format was needed, OR you could use one of the many
`'background' options that script also provides, allowing you to use GIF or even JPEG formats for the resulting summery
`image of the animation.
`
`Other options, lets you define the number of rows or columns to use, as well as set various non-transparent backgrounds,
`or use a red box rather than the default black.
`
`This script will be used a lot during the next few pages of IM Examples. Suggestions and comments are welcome.
`
`Animation Sequence Information - options used to build an animation
`
`As I noted, using "+adjoin" and "-coalesce", as well as "+repage", are all useful methods of extracting and looking at GIF
`animations. However they all destroy information about the original animation in the process.
`
`You can see this extra information on framing, time delays, frame dispose, etc., using the IM "identify" command with a
`"-verbose" option. However I, and probably most other users, find the output from this command, overwhelming and not
`really directly usable.
`
`This is where another special shell script I wrote comes in. The "gif2anim" script will separate the individual frames of the
`animation, but will also figure out exactly what IM "convert" options you would need in order to re-build the animation
`from those images.
`
`You can think of "gif2anim" as a animation disassembler, producing a summary of animation in terms of IM options.
`
`For example, lets decode the animation example we have been using to recover the original "convert" settings used to
`create it, as well as individual images used...
`
` gif2anim canvas_prev.gif
`
`
`
`
`
`
`
`
`
`By default the "gif2anim" script uses the same base file name for the individual images and ".anim" options file. As such
`the animation sequence file generated by the above command is named "canvas_prev.anim", with the individual frame
`images "canvas_prev_001.gif" to "canvas_prev_005.gif".
`
`https://web.archive.org/web/20120310193613/http://www.imagemagick.org/Usage/anim_basics/
`
`10/21
`
`Page 10 of 21
`
`
`
`Animation Basics -- IM v6 Examples
`6/8/22, 12:32 PM
`If you examine the results more closely you will see that it actually did manage to re-create the original options I used
`when I first created this GIF animation (See Dispose Previous Animation). Also while it is not important to actually
`generating an animation, the size, and timings of the overlaid frames is also listed as a comment, to make it easier to study.
`
`Rather than save the results to a file you can just list the animation sequence options to the screen using a "-l" flag. That is
`just output the animation sequence file, rather than save it, or the individual frame images of the animation.
`
` gif2anim -l canvas_prev.gif
`
`Given a ".anim" file and the individual framing images, a complementary script "anim2gif" can be used
`to re-build the animation.
`
` anim2gif canvas_prev.anim
`
`The "anim2gif" by default will re-create the GIF animation with a "_anim.gif" suffix. You can see that the resulting
`"canvas_prev_anim.gif" animation generated, looks and works exactly like the original animation.
`
`This script simply replaces the special string "BASENAME" used in the "animation sequence file", strips all comments, then
`just pass the convert options that is left into the "convert" command. In other words it treats the above file as a type of
`'convert' script with comments.
`
`The reason a special string was used, is because this then allows you to specify a different base filename than the name of
`the ".anim" file itself. That way you can use a completely different set of frame images, such as modified versions of the
`original, to recreate a different animation from the old one. This is very useful feature, which will used in more complex
`animation processing. (See Appending Animations Side-By-Side for an example).
`
`Like "gif2anim", the "anim2gif" script has quite a number of useful options, to help you process and modify animations.
`Some of these options will be used later. For example see Appending Animations.
`
`Also as the ".anim" file is plain text you can use it take the decoded images of an animation to adjust the GIF's meta-data,
`such as the timings, positions, repeating sections of an animation, or adding new frames and images to an animation. This
`was after all why I originally wrote the scripts, long before I got involved with IM examples.
`
`For now the "gif2anim" will be most useful for examining an animation sequence to see just what is happening, and the
`timings that is being applied between frames.
`Dispose Images - the GIF dispose form of the frames
`
`This special "-layers" method, 'Dispose' shows what the frame should look like after the time delay is finished, and the
`GIF dispose method has been applied, but before the next frames image is overlaid.
`
`In other words this show exactly what the GIF "-dispose" method setting actually does to the frame, allowing you figure
`out exactly what is going wrong with your animation.
`
`For example here is how each of our three D