Pages

Friday 26 September 2014

Gif animation using ImageMagick Command-Line

I have used GIFs in a number of presentations I have done and they are very useful if, like me, you are working with images/data which changes over time. Luckily I have found a very easy method of converting an image sequences into a GIF.

All you need is a working installation of ImageMagick.

The second thing you need is, of course, the image sequence itself. This should be properly named with a sequence number defining the relation between the subsequent images.

As an example lets consider you have a folder which contains an images with the following names:
image_XX.png,
where XX can be represents the sequence number of an individual image.

Now all you need is to use command prompt in windows (or terminal in linux) to navigate to that folder. Once inside the folder a simple command based on convert functionality within ImageMagick can convert the images into an animated GIF.

Here is an example:
convert   -delay 20   -loop 0   image_*.png  imageGif.gif
Update (17/12/2016): ImageMagick's update has changed convert to magick. Now the following code works:
magick    -delay 20   -loop 0   image_*.png  imageGif.gif
This will create a gif with delay of 20ms between each image.
The loop option defines the number of times the animation will repeat. A 0 for loop means that it will loop forever.

Now lets see some of the gif animations I have created over the years using this method:





Source:
http://www.tjhsst.edu/~dhyatt/supercomp/n401a.html