gifsicle - manipulates GIF images and animations
gifsicle [options, frames, and filenames]...
gifsicle is a powerful command-line program for manipulating GIF image files. Extensive options let you control what exactly it does.
This man page assumes that you know what GIFs and GIF animations are. For a tutorial, you might try some of the resources listed on-line at webreference.com: http://www.webreference.com/authoring/graphics/animation.html
Without options, gifsicle acts like a filter: you feed it a GIF on standard input, and it writes that GIF on standard output. That means these two commands do the same thing:
% gifsicle < in.gif > out.gif % gifsicle < in.gif | gifsicle | gifsicle | gifsicle > out.gif
Well, that's not very interesting! Most times you'll tell gifsicle to alter its inputs by giving it command line options. The -i option, for example, tells it to interlace its input files:
% gifsicle -i < pic.gif > interlaced-pic.gif
This style doesn't work very well if you want to modify GIF files in place. For that, you should use the --batch option: with --batch, gifsicle will modify the files you specify instead of writing a new file to the standard output. To interlace all the GIFs in the current directory, you could say:
% gifsicle --batch -i *.gif
gifsicle is good at creating and manipulating GIF animations. The simplest way to create an animation is to give more than one input file, which gifsicle will combine to create a ``flipbook'' animation:
% gifsicle pic1.gif pic2.gif pic3.gif > animation.gif
Options like --delay, --loopcount, and --optimize will help you tune your animations; see their descriptions for more details.
The next sections index gifsicle's options and describe them in gory detail. New users may want to skip to the Examples section at the end.
This index is meant to help you find options that do what you want. Concepts are on the left, relevant gifsicle options are on the right.
Animations, changing ... | frame selections, frame changes, etc. | |
disposal ... | --disposal | |
looping ... | --loopcount | |
portions of ... | frame selections | |
smaller ... | --optimize, --colors | |
speed ... | --delay | |
Background color ... | --background | |
Colors, changing ... | --change-color, --use-colormap, --dither, --transform-colormap | |
reducing number ... | --colors, --dither | |
Comments ... | --comment | |
Extensions ... | --extension, --app-extension, --extension-info | |
File size ... | --optimize, --unoptimize, --colors | |
Image transformations ... | ||
cropping ... | --crop | |
flipping ... | --flip-* | |
resizing ... | --resize, --scale | |
rotating ... | --rotate-* | |
Grayscale ... | --use-colormap | |
Interlacing ... | --interlace | |
Positioning frames ... | --position | |
Screen, logical ... | --logical-screen | |
Selecting frames ... | frame selections (like #0) | |
Transparency ... | --transparent | |
Warnings ... | --no-warnings | |
Web-safe palette ... | --use-colormap |
gifsicle's command line consists of GIF input files and options. Most options start with a dash (-) or plus (+); frame selections, a kind of option, start with a number sign (#). Anything else is a GIF input file.
gifsicle reads and processes GIF input files in order. If no GIF input file is given, or you give the special filename `-', it reads from the standard input.
gifsicle exits with status 0 if there were no errors and status 1 otherwise.
Every option has a long form, `--long-descriptive-name'. You don't need to type the whole long descriptive name, just enough to make it unambiguous.
Some options also have a short form, `-X'. You can combine short options if they don't take arguments: `-IIb' is the same as `-I -I -b'. But be careful with options that do take arguments: `-cblah' means `-c blah', not `-c -b -l -a -h'.
Many options also have a converse, `--no-option', which turns off the option. You can turn off a short option `-X' by saying `+X' instead.
Mode options tell gifsicle what kind of output to generate. There can be at most one mode option, which must precede any GIF inputs.
General options control what information gifsicle prints and where it writes its output. The info options and --verbose can be turned off with `--no-X'.
A frame selection tells gifsicle which frames to use from the current input file. They are useful only for animations, as non-animated GIFs only have one frame. Here are the legal forms for frame specifications.
For example,
gifsicle happy.gif
will use all of `happy.gif's frames, while
gifsicle happy.gif #0
will only use the first.
What gifsicle does with the selected frames depends on the current mode. In merge mode, only the selected frames are merged into the output GIF. In batch mode, only the selected frames are modified; other frames remain unchanged. In explode mode, only the selected frames are exploded into output GIFs.
Frame change options insert new frames into an animation or replace or delete frames that already exist. Some things -- for example, changing one frame in an animation -- are difficult to express with frame selection, but easy with frame changes.
The frames arguments are frame selections (see above). These arguments always refer to frames from the original input GIF. So, if `in.gif' has 3 frames and `other.gif' has one, this command
gifsicle in.gif --delete #0 --replace #2 other.gif
will produce an output animation with 2 frames: `in.gif' frame 1, then `other.gif'.
The other-GIFs arguments are any number of GIF input files and frame selections. These images are combined in merge mode and added to the input GIF. The other-GIFs last until the next frame change option, so this command replaces the first frame of `in.gif' with the merge of `a.gif' and `b.gif':
gifsicle -b in.gif --replace #0 a.gif b.gif
This command, however, replaces the first frame of `in.gif' with `a.gif' and then processes `b.gif' separately:
gifsicle -b in.gif --replace #0 a.gif --done b.gif
Warning: You shouldn't use both frame selections and frame changes on the same input GIF.
Image options modify input images (by changing their interlacing, transparency, and cropping, for example). Each image option stays in effect until the next image option in the same category. They have three forms: `--X', `--no-X', and `--same-X'. The default is `--same-X', which means that X's value is copied from each input. The converse, `--no-X', erases X; for instance, --no-interlace turns interlacing off, while --no-comments strips comments. Only the `--X' form is generally described.
Extension options add non-visual information to the output GIF. This includes names, comments, and generic extensions.
--no-comments and --same-comments affect all the images following, and apply only to input GIF comments, not ones added with --comment.
--no-extensions (or +x) and --same-extensions affect all the images following, and apply only to input GIF extensions.
--no-names and --same-names affect all the images following. They apply only to input GIF names, not ones added with --name.
Animation options are image options applying only to GIF animations. Most of them act like image options, and have the same three forms (see above).
- -O1
- Stores only the changed portion of each image. This is the default.
- -O2
- Also uses transparency to shrink the file further.
There is no --same-optimize option.
GIF animations are often optimized (see --optimize) to make them smaller and faster to load, which unfortunately makes them difficult to edit. --unoptimize changes optimized input GIFs into unoptimized GIFs, where each frame is a faithful representation of what a user would see at that point in the animation.
There is no --same-unoptimize option.
Whole-GIF options effect entire GIFs as they are read or written. They can be turned off with `--no-option'.
Unless you give --use-colormap, an adaptive group of colors is chosen from the existing color table. You can affect this process with the --color-method option. Gifsicle may need to add an additional color (making num+1 in all) if there is transparency in the image.
Text colormap files have a very simple format:
# each non-comment line represents one color, "red green blue" # each component should be between 0 and 255 0 0 0 # like this 255 255 255
Here are a bunch of examples showing how gifsicle is commonly used.
First, let's create an animation, `anim.gif':
% gifsicle a.gif b.gif c.gif d.gif > anim.gif
This animation will move very quickly: since we didn't specify a delay, a browser will cycle through the frames as fast as it can. Let's slow it down and pause .5 seconds between frames, using the --delay option.
% gifsicle --delay 50 a.gif b.gif c.gif d.gif > anim.gif
If we also want the GIF to loop three times, we can use --loopcount:
% gifsicle -d 50 --loop=3 a.gif b.gif c.gif d.gif > anim.gif
(Rather than type --delay again, we used its short form, -d. Many options have short forms; you can see them by running `gifsicle --help'. We also abbreviated --loopcount to --loop, which is OK since no other option starts with `loop'.)
To explode `anim.gif' into its component frames:
% gifsicle --explode anim.gif
% ls anim.gif*
anim.gif anim.gif.000 anim.gif.001 anim.gif.002 anim.gif.003
To optimize `anim.gif':
% gifsicle -b -O2 anim.gif
To change the second frame of `anim.gif' to `x.gif':
% gifsicle -b --unoptimize -O2 anim.gif --replace #1 x.gif
--unoptimize is used since `anim.gif' was optimized in the last step. Editing individual frames in optimized GIFs is dangerous without --unoptimize; frames following the changed frame could be corrupted by the change. Of course, this might be what you want.
Note that --unoptimize and --optimize can be on simultaneously. --unoptimize affects input GIF files, while --optimize affects output GIF files.
To print information about the first and fourth frames of `anim.gif':
% gifsicle -I #0 #3 < anim.gif
(information printed)
To make black the transparent color in all the GIFs in the current directory, and also print information about each:
% gifsicle -bII --trans #000000 *.gif
(information printed)
Giving -I twice forces normal output to occur. With only one -I, the GIFs would not have changed on disk.
To change `anim.gif' to use a 64-color subset of the Web-safe palette:
% gifsicle -b --colors=64 --use-col=web anim.gif
To make a dithered black-and-white version of `anim.gif':
% gifsicle --dither --use-col=bw anim.gif > anim-bw.gif
Please email suggestions, additions, patches and bugs to eddietwo@lcs.mit.edu.
Eddie Kohler <eddietwo@lcs.mit.edu>
http://www.pdos.lcs.mit.edu/~eddietwo/
He wrote it.
Anne Dudfield <anne@lvld.hp.com>
http://www.frii.com/~annied/
She named it.
Hans Dinsen-Hansen <dino@danbbs.dk>
http://www.danbbs.dk/~dino/
Adaptive tree method for GIF writing.
http://www.lcdf.org/~eddietwo/gifsicle/
Back to
The
gifsicle home page.