Creating an Animated GIF Image
by D.W. Hyatt
Creating an Animation
Various graphic images can be animated using a module from the UNIX program
called ImageMagick. The graphics can be either grabbed with xv
from a running program or generated by some other means.
To simplify the animation process, the files should be named in
some logical sequence so that the order they are listed in the
directory is the order in which they are to be animated. ImageMagick can handle a number of different file formats, but in this case we will use .gif
because eventually we will make an animated GIF image for use on a
web page.
To just animate the various frames, just type:
-
animate
sphere*.gif
sphere00.gif
|
sphere01.gif
|
sphere02.gif
|
sphere03.gif
|
sphere04.gif
|
sphere05.gif
|
sphere06.gif
|
sphere07.gif
|
sphere08.gif
|
sphere09.gif
|
sphere10.gif
|
sphere12.gif
|
This will take the files that start with sphere and end with .gif
and will animate them in sequence depending upon their file names. That is
why it is convenient to have them named with a numerical value attached.
With ImageMagick, there are controls to speed up or slow down the animation
as well as make it go forward or reverse.
Making an Animated GIF Image
To create an animated GIF image, ImageMagick has another routine that is
quite helpful called convert. Although it is possible to convert
directly from the PPM images, it is better to use xv to make
some smaller GIF images of each frame, and then use the command:
-
convert
-delay 20
-loop 0
sphere*.gif
animatespheres.gif
This will take all of the source frames and will make them into one
animated GIF image called animatespheres.gif. The -delay 20
argument will cause a 20 hundredths of a second delay between each frame,
and the -loop 0 will cause the gif to loop over and over again.
Click on the image to the right to see it animate.