How to Change GIF Frame Delay with ImageMagick?
Changing the frame delay of an existing animated GIF is a
straightforward process using ImageMagick’s convert (or
magick) command. By utilizing the -delay
setter alongside the -loop option, you can precisely
control how long each frame displays and how many times the animation
repeats. This article provides a quick guide on how to adjust these
timing settings for the entire animation or for specific individual
frames, ensuring your GIF plays at the exact speed you require.
Modifying the Delay for the Entire GIF
To change the speed of all frames uniformly, you need to specify the
new delay before importing your input GIF, and then use the
-layers Optimize flag to ensure the output file remains
efficient and uncorrupted.
ImageMagick measures time in ticks, where 100 ticks
equal 1 second. Therefore, a value of 20 represents
20/100ths of a second (200 milliseconds), making the animation run at 5
frames per second.
magick convert -delay 20 input.gif -loop 0 output.gifIn this command:
-delay 20sets the display time for subsequent frames to 200ms.-loop 0ensures the animated GIF loops indefinitely.
Adjusting Speed for Specific Frames
If you only want to change the duration of a single frame—for
example, making the very first frame pause longer than the rest—you can
target that specific frame index using square brackets [ ].
Frame indexing starts at 0.
magick convert input.gif -delay 100 -morphology identity [0] -delay 20 [1-top] output.gifAlternatively, you can break the GIF apart, apply different delays to different sections, and merge them back together in a single command line sequence to create dynamic timing changes within the same file.
Overriding Existing Frame Animation Delays
Sometimes, an existing GIF has baked-in timing metadata that resists
global changes. To completely erase the old timing characteristics and
force your new speed limits, use the -set delay command
modifier.
magick convert input.gif -set delay 15 output.gifUsing -set delay directly alters the image metadata for
every frame currently in the image sequence wrapper, safely overwriting
whatever pacing the original creator embedded in the file.