Animating GIF Images
MultiGIF is a cross-platform utilty for creating animated GIF images. Given an initial set of GIF images, you can use MultiGIF to combine them into a single multi-image GIF file. When viewed with a web browser these images appear sequentially as frames of an animation.
MultiGIF is free software distributed under the terms of the Gnu Public License. See the LICENSE file in the distribution for details.
MultiGIF is written in portable C and should compile without problem with any ANSI-compliant C compiler. A Makefile is provided for your convenience. Edit the Makefile to set any options (see the comments in the Makefile) and then run "make".
Source Images
Output Image
Command Line
$ multigif -o spin.gif -n 0 -d 200:10:10:10 -l 1-4 -v right.gif up.gif left.gif down.gif
MultiGIF is invoked as a command line utility. You can specify options as command line parameters or create a command file and pass the option "@filename" to MultiGIF. You can freely mix commmand line parameters and command files.
For example, if you have a file called "prm" with the following contents:
-b 0 -c "This is a comment" -g 4
Then running MultiGIF as:
$ multigif @prm
is exactly the same as if you had typed:
$ multigif -b 0 -c "This is a comment" -g 4
You can also add further options to the command line:
$ multigif -o outfile.gif @prm -v foo.gif bar.gif baz.gif
Command line options may, or may not, have spaces between the command letter and value. i.e. "-ooutfile.gif" is the same as "-o outfile.gif". Options specified in a command file may appear on the same, or on different lines. Options may be stated in any order.
Be warned that some parameters will need to be quoted ("") to avoid problems. For example, a comment with spaces will need to be quoted to prevent the parser from thinking that the seperate words are additional parameters:
-c "This is a comment" # good -c This is a comment # bad
Also note that parameters containing certain characters (e.g. '*' and '?') may need to be quoted to prevent the shell interpreting them.
The basic usage of MultiGIF is as follows:
$ multigif [options] files (or multigif @paramfile)
This will create a multi-image GIF from the files specified, using all default parameters. e.g.
$ multigif foo.gif bar.gif baz.gif
The following options are available. This table can be reproduced by invoking MultiGIF with the help (-h) option:
-b colour Background colour index (default: 0) -c "comment" Add comment to output GIF file -g frame Use palette from <frame> as a global palette (default: 1) -n count Add a Netscape loop of <count> iterations -o file Output file name (default: multigif.gif) -d "n:n:n..." Delays (1/100s) for each frame. Frame repetions may be specified as "d*r" - delay <d> for <r> frames -r "n:n:n..." Replace modes for each frame, specified as above 0/1 - None, 2 - Background, 3 - Restore -x "n:n:n..." X position of frame (default: 0), specified as above -y "n:n:n..." Y position of frame (default: 0), specified as above -l "f,f,f..." List of frames to have a local palette. Range: "a-b" -u "f,f,f..." List of frames to require user input -v Verbose mode -h This help
-b colour
A GIF image can have a colour specified as the background colour. This is the index number of the colour in the global colour table. By default, this is set to colour 0, the first colour (usually black) in the colour table. Legal values are in the range 0-255. The background colour is only valid if the GIF has a global colour table. MultiGIF always adds a global colour table to the destination image.
$ multigif -b 5
-c "comment"
A GIF image can have any number of comment blocks added to it. This allows the creator or manipulator of an image to add information such as copyright notice, name, date, etc. MultiGIF currently only allows one user-defined comment block to be added.
$ multigif -c "Cool Fire (C) 2004 Andy Wardley"
-g frame
MultiGIF adds a global palette to the output file. This is the colour table which images will use if they don't specify their own local palette. By default, MultiGIF will use the palette from the first image (frame 1) as the global palette. The -g option specifies the source image number from which the palette should be taken. Note that the first image specified is image 1, not 0.
$ multigif -g 2 a.gif b.gif c.gif
In this example, MultiGIF will use the global palette (or local palette if it has one) from image 2 (b.gif).
-n count
GIF images can contain "Application Extension Blocks" which allow the image creator or manipulator to add information specific to a certain application. Netscape have used this feature in their Navigator v2.0+ browser to specify a "repeat loop" count.
MultiGIF, when invoked with the -n option will add a Netscape specific Application Extension Block to the output GIF file which tells Netscape Navigator to repeat the animation a number of times. Note that Navigator version 2.0 ignores this value and loops indefinately but the repetition count is supported in versions 3.0+. A loop count of 0 indicates an indefinite loop, although this is not recommended.
Note also that Netscape Navigator only repeats the image if the cache is enabled (Options|Network Preferences|Cache) to avoid reloading the image across the network.
$ multigif -n 25
-o file
By default, MultiGIF creates an output image named "multigif.gif". Use the -o option to specify an alternate name. This name should conform to your platform specific file naming conventions. No checks are made by MultiGIF as to the suitability of the filename, due to the cross-platform nature of MultiGIF.
$ multigif -o coolfire.gif
-d "n:n:n..."
Each image within a multi-GIF file can have a delay associated with it. This specifies the time, in hundredths of a second (1/100s), that should elapse before the image is displayed. This value effectively controls the speed of the animation. By default, a delay of 0 is used.
Delays should be specified for each frame, seperated by colons (:). Empty values, or values for frames not specified will default to 0. To specify the same value for a number of frames, use the "delay*rep" syntax. For example, to indicate a delay of 0.25s for 5 frames, you would specify "25*5".
$ multigif -d "100:25*3:200" a.gif b.gif c.gif d.gif e.gif
The image a.gif (frame 1) will have a 1s delay, b.gif (2), c.gif (3) and d.gif (4) will all have delays of 0.25s and e.gif (5) will have a 2s delay.
-r "n:n:n..."
After the image has been displayed, the replace mode specifies how it should be removed. This is specified for each frame in a colon seperated list as per frame delays, described above. Frame repetitions (mode*rep) may be used.
The replace modes are specified as a number in the range 0-3. These numbers indicate the following modes:
0 | Not Specified | No action (image is left on screen) |
1 | None | No action (image is left on screen) |
2 | Background | Image is replaced with background colour or image. |
4 | Restore | Image is replaced with previous contents of the image area. |
Note that option 3 (Restore) where the image is replaced with the saved contents of whatever it was displayed over, is not yet supported on any known web browser. Images with transparent colours may have problems when displaying over previous images if the image underneath can be seen through the transparent areas. Until this is supported in browsers, the only solution is to use Background mode, or insert a frame restoring the previous screen contents.
$ multigif -r "0:2*3:0" a.gif b.gif c.gif d.gif e.gif
In this example, images a.gif and e.gif (frames 1 and 5) will be left on screen and b.gif (2), c.gif (3) and d.gif (4) will be replaced with the background colour or image.
-x "n:n:n..." -y "n:n:n..."
Each image in a multi-GIF file can be positioned at an offset relative to the top-left corner. This allows small sub-sections of the image to be added as frames, rather than repeating the entire image for each frame. X and Y positions are specified as colon delimited lists, with optional repetition counts (pos*rep) as described above.
Note that the total image size will be as large as is required to place all images in their entirety. This avoids a bug in Netscape which occurs when an image, or part of an image, is positioned outside the "global" GIF area specified in the image header.
$ multigif -x "0:48*3:50" -y "0:24*3:60" a.gif b.gif c.gif d.gif e.gif
In this example, a.gif (frame 1) is positioned at XY 0,0, b.gif (2), c.gif (3) and d.gif (4) are all positioned at XY 48,24, and e.gif (5) is positioned at XY 50,60.
-l "f,f,f..."
By default, images in a multi-GIF file created by MultiGIF will use the global palette. You can specify that images should use their own local palette with the -l option. The parameter should be a comma seperated list of frame numbers. Frame numbers are identified by the order the source filenames are presented on the command line, starting at 1. A range of frames may be specified using a hyphen. For example "3-5" indicates the frames 3, 4 and 5.
$ multigif -l "1,3-5" a.gif b.gif c.gif d.gif e.gif
Local palettes would be used for the frames built from files a.gif (frame 1), c.gif (3), d.gif (4) and e.gif (5). The image b.gif (2) would use the global palette which would, by default, be the palette taken from the first frame (a.gif).
-u "f,f,f..."
The GIF standard specifies that a User Input Flag can be set for each image. This requires the user to intervene (say, by pressing a key) before the image is displayed. Although browsers do not currently support this feature, it is supported by MultiGIF. Frames requiring user input should be specified as a comma-delimited list of frame numbers, with optional ranges, as described about.
$ multigif -u "1,3-5"
-v
MultiGIF running in verbose mode displays information about the source and destination images as it processes them.
MultiGIF maintains the transparency and interlace conditions of source files as is incorporates them.
The image size of the resulting GIF file will be as large as is necessary to fully incorporate all source images.
Options specified for frames that do not exist (e.g. specify delay values for 5 frames, but only provide 3 source GIF filenames) will be ignored.
The use of the colon (:) and comma (,) to seperate frame flags and lists in command line parameters is interchangeable.
The source archive for MultiGIF also contains a simple utility, gifinfo, which reads and displays information about a GIF file, including multiple images. Simple run gifinfo with the filename of the GIF file you wish to examine.
$ gifinfo coolfire.gif
MultiGIF is Copyright © Andy Wardley 1996-2004. All Rights Reserved.
MultiGIF is Free Software distributed under the terms of the GNU Public License.
MultiGIF does compress or uncompress any GIF image blocks. As such, it does not encode any part of the LZW algorithm and is not encumbered by the patents that cover the GIF format.