Pass arguments to the convert tool to turn a directory of images into an animated GIF—all without opening a GUI tool.
The convert utility has plenty of tricks up its sleeve. One of the tricks is the simple conversion of a series of images into a single animated GIF file. Since convert can handle a large variety of image formats, you don’t even need to start out with a directory of GIF-only images.
When it comes to image processing, convert
does a lot of the heavy lifting on its own. In fact, the only option you
need to concern yourself with is the -delay
option, which specifies, in
milliseconds, how long to wait between each image change. You can use
the animate tool from the ImageMagick suite to test
your animation. To see what your animation would look like with a
one-second delay on a directory full of GIF images, type:
$ animate -delay 100 *.gif
This command displays each image in alphabetical order, one after
the other. If you want to display them in a different order, specify the
images in that order on the command line. Once you are satisfied with
your delay rate you can use the same number with the convert
command. To convert a directory of GIF
files into a single animated GIF with one second between frames,
type:
$ convert -delay 100 *.gif
animated.gif
Because I used a file glob here, I assumed the images were in alphabetical sequence. If they aren’t in order, either specify each file on the command line (with the animated GIF specified last) or rename the files so that they are sequential. To see your newly created animated GIF, type:
$ display animated.gif