gifsicle
create, edit, and optimize GIF images and animations
TLDR
SYNOPSIS
gifsicle [options, frames, and filenames] ...
DESCRIPTION
gifsicle manipulates GIF images and animations from the command line: it merges files into animations, explodes animations into frames, edits individual frames in place, and reduces file sizes, all without a GUI.Its arguments are order-dependent, which is what distinguishes it from most tools. Options, frame selections and filenames are read left to right, and an option applies to the input files that follow it. Frame selections use # notation attached to a file: '#0' is the first frame, '#0-5' a range, '#-1' the last. Quote them, since # starts a comment in most shells.Optimization is the feature most people come for. -O3 tries several encodings per frame and keeps the smallest, typically cutting an unoptimized animation substantially by storing only inter-frame differences, losslessly. When that is not enough, --lossy trades exactness for size by allowing nearby colors to be merged, and --colors shrinks the palette outright.By default gifsicle runs in merge mode, combining all inputs into a single output written with -o. --batch switches to editing each input file in place, and --explode writes one file per frame.
PARAMETERS
-o, --output file
Write output to file. Use - for standard output.-O, --optimize[=level]
Optimize output. 1 stores only the changed portion of each frame (the default when -O is given without a level), 2 also uses transparency, 3 tries several methods and picks the best, which is slower.--lossy[=lossiness]
Alter colors to shrink the file at the cost of artifacts. Higher values mean smaller files and more noise. Default 20.-U, --unoptimize
Expand each frame to a full-size image. Useful before editing individual frames.--resize WxH
Resize to exact dimensions. Use _ for a dimension to preserve the aspect ratio.--resize-width W, --resize-height H
Resize to a width or height, preserving the aspect ratio.--resize-fit WxH
Shrink to fit inside a rectangle, preserving the aspect ratio. Does nothing if the GIF already fits.--resize-fit-width W, --resize-fit-height H
Shrink to fit a width or height, preserving the aspect ratio.--resize-method method
Resampling method: sample (fast, noisy when shrinking), mix (default, better quality), box, catrom, mitchell, lanczos2, lanczos3.--scale Xfactor[xYfactor]
Scale by a factor, e.g. 0.5 for half size. Yfactor defaults to Xfactor.--crop x1,y1+WxH, --crop x1,y1-x2,y2
Crop to a region. Zero dimensions extend to the image edge; negative values retract from it.--crop-transparency
Crop away transparent borders.-d, --delay time
Frame delay in hundredths of a second.-l, --loopcount[=count]
Set the Netscape loop extension to count, or forever. --loopcount alone means forever. The default is --no-loopcount, which adds no loop extension.-k, --colors num
Reduce to num colors, between 2 and 256.--color-method method
Color reduction method: diversity (default, xv's algorithm), blend-diversity, median-cut (Heckbert's algorithm).-f, --dither[=method]
Dither when the colormap changes. Methods include floyd-steinberg (default), atkinson, ordered, halftone, ro64, o3, o4, o8.--rotate-90, --rotate-180, --rotate-270
Rotate the image.--flip-horizontal, --flip-vertical
Flip the image.-e, --explode
Write each frame to a separate file named file.number.-m, --merge
Merge mode: combine inputs into one output. This is the default.-b, --batch
Batch mode: modify each input file in place.-I, --info
Print information about the input GIFs instead of writing an output file.--careful
Write slightly larger GIFs that avoid bugs in some other GIF readers, notably older Java and Internet Explorer versions.--conserve-memory
Use less memory at the cost of speed, for very large GIFs.-w, --no-warnings
Suppress warning messages.
INSTALL
CAVEATS
Input must already be a GIF. gifsicle does not read PNG, JPEG or video, so pair it with ffmpeg or ImageMagick's convert to produce the GIF first, then optimize it here.Because arguments are positional, gifsicle --colors 64 a.gif b.gif and gifsicle a.gif --colors 64 b.gif are not the same command. Options placed after a file do not apply to it retroactively.The default is --no-loopcount, so an animation you assemble will play once unless you pass --loopcount=forever. Note also that count is the number of repetitions *after* the first play-through, so --loopcount=3 shows the animation four times.-b rewrites your originals with no backup. Confirm the result on a copy before running it across a directory.--lossy and --colors are not reversible, and repeatedly re-optimizing an already-lossy GIF compounds the artifacts.Large animations can use a lot of memory, particularly with -U, which expands every frame to full size; --conserve-memory trades speed for footprint.
HISTORY
gifsicle was written by Eddie Kohler and first released in 1997, growing out of his earlier work on GIF tools while he was a graduate student. It became a standard tool for GIF manipulation and web optimization, and is the engine behind many "shrink this GIF" services. Development continues on GitHub, with --lossy added in 2015 based on work from the giflossy fork.
SEE ALSO
convert(1), ffmpeg(1), optipng(1), pngquant(1), imagemagick(1)
