ImageMagick KnowledgeBase
GIF Animations and Animation Meta-data
Example 1
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
Example 2
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
Frame Disposal Methods
Example 1
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
Example 2
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 \
-page +10+55 shading.gif \
-loop 0 canvas_none.gif
Example 3
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
Example 4
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
Example 5
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
Studying Animations
Identify
information about and animation
Example 1
identify canvas_prev.gif
Example 2
identify -format "%f canvas=%Wx%H size=%wx%h offset=%X%Y %D %Tcs\n" \
canvas_prev.gif
Adjoin
splitting an animation into frames
Example 1
convert canvas_prev.gif -scene 1 +adjoin frame_%03d.gif
Example 2
convert frame_???.gif anim_rebuilt.gif
Example 3
convert canvas_prev.gif +repage -set delay 0 -set dispose None \
+adjoin repage_%03d.gif
Coalesce
fill out frames completely
Example 1
convert script_k.gif +repage +adjoin script_k_%02d.gif
Example 2
montage script_k.gif -coalesce \
-tile x1 -frame 4 -geometry '+2+2' \
-background none -bordercolor none coalesce_k_montage.gif
Animation Frame Montage
the "gif_anim_montage" script
Example 1
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
Example 2
gif_anim_montage script_k.gif script_k_frames.gif
Example 3
gif_anim_montage -u script_k.gif script_k_frames.png
Animation List Information
options used to build an animation
Example 1
gif2anim canvas_prev.gif
Example 2
gif2anim -l canvas_prev.gif
Example 3
anim2gif canvas_prev.anim
Dispose Images
the GIF dispose form of the frames
Example 1
convert canvas_none.gif -layers Dispose canvas_none_dispose.gif
gif_anim_montage canvas_none_dispose.gif canvas_none_dispose_frames.gif
Example 2
convert canvas_prev.gif -layers Dispose canvas_prev_dispose.gif
gif_anim_montage canvas_prev_dispose.gif canvas_prev_dispose_frames.gif
Example 3
convert canvas_bgnd.gif -layers Dispose canvas_bgnd_dispose.gif
gif_anim_montage canvas_bgnd_dispose.gif canvas_bgnd_dispose_frames.gif
Deconstruct
report areas of frame differences
Example 1
convert canvas_prev.gif -coalesce coalesce.gif
convert coalesce.gif -deconstruct deconstruct.gif
gif_anim_montage coalesce.gif coalesce_frames.gif
gif_anim_montage deconstruct.gif deconstruct_frames.gif
Example 2
convert canvas_bgnd.gif -coalesce -deconstruct deconstruct_erase.gif
Frame Comparisons
more detailed comparing of frames
Example 1
convert canvas_bgnd.gif -coalesce canvas_bgnd_coal.gif
gif_anim_montage canvas_bgnd_coal.gif canvas_bgnd_coal_frames.gif
convert canvas_bgnd_coal.gif -layers CompareAny compare_any.gif
gif_anim_montage compare_any.gif compare_any_frames.gif
Example 2
convert canvas_bgnd_coal.gif -quiet -layers CompareClear compare_clear.gif
gif_anim_montage compare_clear.gif compare_clear_frames.gif
Example 3
convert canvas_bgnd_coal.gif -layers CompareOverlay compare_overlay.gif
gif_anim_montage compare_overlay.gif compare_overlay_frames.gif
Types of Animations
Coalesced Animations
Overlay Animations
Cleared Frame Animations
Example 1
convert bunny_grass.gif bunny_anim.gif -loop 0 bunny_on_grass.gif
Example 2
convert any_animation.gif -coalesce -trim \
-set dispose previous cleared_frame_animation.gif
Example 3
convert bunny_grass.gif \( bunny_anim.gif -repage 0x0+5+15\! \) \
-loop 0 bunny_on_grass2.gif
Example 4
convert bunny_grass.gif \( bunny_anim.gif -repage 0x0+5+15\! \) \
-coalesce -delete 0 -deconstruct -loop 0 bunny_bgnd.gif
gif_anim_montage bunny_bgnd.gif bunny_bgnd_frames.gif
Mixed Disposal Animations
multi-background animations
The End of the Loop
when an animation stops
Zero Delay Intermediate Frames
Sources and References
https://legacy.imagemagick.org/Usage/anim_basics/