How to create an animated GIF from a series of images

Sometimes, you end up with a folder full of images, which you want to animate. With the open source ImageMagick tool, this is easy on the command line:

animate *.png

This will show you all of the PNG files in the folder in quick succession, like a flip book.

ImageMagick works on just about any OS. For Linux users, it should be in your package manager.

On Debian you would install it via:

sudo apt-get install imagemagick

Or on Red Hat it is:

sudo yum install ImageMagick

But this blog post is about animated GIFs, so lets make one of those. This is a compact way to combine images (here and here for examples in context), gives you a re-usable at-a-glance illustration of something that changes over time.

Example from an older post:

The steps to make a good conversion command are below.

Check that alphabetically, your images are in order. If not, rename them:

echo *

Convert them to a GIF, and find the delay that suits you (hundredths of a second between frames). You will want to repeat this a few times to find the delay value which works for you:

convert -delay 80 *.png animated.gif

Choose an output size (width x height):

convert -resize 415x -delay 80 *.png animated.gif

Compress with -Layers Optimize for a smaller file:

convert -resize 415x -delay 80 *.png -layers Optimize animated.gif

Notes

  • Generated thumbnails usually take the first frame only, which is why we ask Imagemagick to resize it (Wordpress users: Choose “Full Size”).
  • To pause at the start of the loop for a moment, just copy the first image a few times.