gifsicle
TLDR
Optimize a GIF for smaller file size
SYNOPSIS
gifsicle [options] [input.gif ...] [-o output.gif]
DESCRIPTION
gifsicle is a command-line tool for creating, editing, and optimizing GIF images and animations. It can manipulate existing GIFs, combine multiple images into animations, extract frames, and significantly reduce file sizes.
The optimization feature is particularly valuable: level 3 optimization can reduce GIF file sizes by 30-50% without quality loss by storing only changed pixels between frames and finding optimal color palettes.
Frame selection uses '#' notation: '#0' is the first frame, '#0-5' selects frames 0 through 5, '#0-' selects from frame 0 to the end. This allows extracting, deleting, or rearranging specific frames.
For creating animations, gifsicle combines individual GIF frames with configurable delays and loop counts. It handles disposal methods correctly to produce proper animations from separate images.
The tool operates as a filter by default (reading stdin, writing stdout) but typically uses -o for output. The --batch flag enables in-place editing of multiple files.
PARAMETERS
-o, --output file
Write output to file.--optimize, -O [level]
Optimize GIF (1=store only changed, 2=shrink, 3=max).--resize WxH
Resize to specified dimensions.--resize-width W
Resize to width, maintaining aspect ratio.--resize-height H
Resize to height, maintaining aspect ratio.--scale factor
Scale by factor (e.g., 0.5 for half size).--delay time
Set frame delay in hundredths of a second.--loopcount n
Set loop count (0 or forever for infinite).--colors n
Reduce to n colors (2-256).--color-method method
Color reduction method: diversity, blend-diversity, median-cut.--crop x,y+WxH
Crop to specified region.--rotate-90, --rotate-180, --rotate-270
Rotate image.--flip-horizontal, --flip-vertical
Flip image.--unoptimize, -U
Unoptimize (expand each frame to full image).--explode
Write each frame to separate file.--info, -I
Show information about the GIF.--batch, -b
Modify files in place.
CAVEATS
Input must be valid GIF format. Very large GIFs may require significant memory. Heavy optimization can be slow on complex animations. Color reduction may cause visible quality loss. Does not convert from other formats (use ImageMagick for that).
HISTORY
gifsicle was written by Eddie Kohler starting in 1997 at UCLA. It became a standard tool for GIF manipulation in the open-source community, particularly for web optimization. The tool predates the web's animated GIF renaissance but remains highly relevant for creating and optimizing GIFs.


