How to Resize an Animated GIF with ImageMagick?

To resize an animated GIF without losing its animation or ruining its optimization using ImageMagick, you must use the -coalesce command before resizing and the -layers Optimize command afterward. This process unpacks the individual frames, scales them uniformly, and then re-compresses them to keep the file size manageable. Failure to include these specific steps will result in a distorted, broken, or completely static image.

The Core Command

The standard syntax for resizing an animated GIF properly requires a specific sequence of operations. You can run the following command in your terminal:

convert input.gif -coalesce -resize 500x500 output.gif

If you want to ensure the file size remains small and the animation layers are re-optimized after the resize, use this expanded version:

convert input.gif -coalesce -resize 500x500 -layers Optimize output.gif

Breaking Down the Code

Resizing by Percentage

If you prefer to scale the image by a specific percentage rather than defining exact pixel dimensions, you can replace the pixel values with a percentage flag:

convert input.gif -coalesce -resize 50% -layers Optimize output.gif

Using this method ensures that every frame is scaled down by exactly half, preserving both the original proportions and the animation timeline flawlessly.