Make Animated GIFs with ImageMagick

There’s been a recent resurgence in animated GIFs. Maybe it’s because they’re easier to share on GitHub, Imgur and Twitter. Videos usually need a player and don’t work everywhere. It’s like we’re back in the ’90s again.

Animated GIFs don’t have as good compression as video codecs so tend to be much larger. Yet they can be acceptable for non-natural video. For example screencasts with lots of solid colour. For natural video of real scenes you need to be careful.

For example this is an animated GIF of my Blinky Tube Status. It’s composed of JPEGs but they’re cropped and there are only two frames. There is still quite a bit of noise and it looks grainy.

blinkytape tube strike

Where they shine is when composing animations from smartphone screenshots. Scroll down for instructions, but first some examples.

Android Screenshots

This is an animation of screenshots from my mobile tube status at It shows the progression of a strike and the order in which the lines closed.

tube strike

Here is a similar animation of the Vulcan XH558 Android app. It shows the progression of status over time.

vulcan status

This is the same app tracing the route taken by the plane over a map of the UK.

vulcan route

Making GIFs

ImageMagick is a great piece of command line software for manipulating images. You can combine it with FFMPEG to turn videos into GIFs. There is a good guide on that but I started with screenshots. In newer versions of Android press lock and volume down together to capture a screenshot. On iOS press lock and home together. Retrieve the PNG images from the phone over USB.

The following command uses ImageMagick to create an animated GIF from a set of PNG images. You can specify the time between frames and if it repeats.

convert -delay 30 -loop 0 *.png anim.gif

Cropping an animated GIF is a bit more complex. If you use a basic crop it will become corrupted. The following command works well. You will need to adjust the crop pixels. This removes the 80px top status bar and the bottom button bar.

convert anim.gif -coalesce -repage 0x0 -crop 1080x1700+0+80 +repage animcrop.gif

You may want to shrink your GIF if the file size is too big. This command makes the image half the size. It preserves the animation which other software may not do.

convert animcrop.gif -resize 50% animcropsmall.gif

This blog is treeware! If you found it useful then please plant a tree.
Donate a treeDonate a tree🌳🌳