gifsicle — Create, Optimize and Edit Animated GIFs

Practical guide to gifsicle: create, optimize and edit animated GIFs on the command line — manipulate frames, tweak timing and shrink file size.

gifsicle is the Swiss Army knife for GIFs on the command line: it creates, optimizes and edits animated GIFs, extracts or deletes individual frames, adjusts timing and loop behavior, and shrinks file size dramatically with -O3, --colors and --lossy. Keep two things in mind, though: --lossy is a lossy operation, and --batch (-b) edits files in-place, overwriting the original. Make a backup first or write the result to a separate output file.

Basic Usage

gifsicle <input.gif> -o <output.gif> — Read and write a GIF (basic copy).

gifsicle animation.gif -o copy.gif

gifsicle -I <input.gif> — Display information about a GIF (frames, dimensions, colors).

gifsicle -I animation.gif

gifsicle --info --color-info <input.gif> — Show detailed info including color table and frame data.

gifsicle --info --color-info animation.gif

gifsicle --explode <input.gif> — Extract all frames as individual GIF files.

gifsicle --explode animation.gif

gifsicle <input.gif> '#0' -o <output.gif> — Extract a single frame (0-indexed).

gifsicle animation.gif '#0' -o first-frame.gif

Optimization

gifsicle -O3 <input.gif> -o <output.gif> — Maximum optimization (best compression, slowest).

gifsicle -O3 animation.gif -o optimized.gif

gifsicle -O2 <input.gif> -o <output.gif> — Standard optimization (good balance of speed and size).

gifsicle -O2 animation.gif -o optimized.gif

gifsicle -O3 --lossy=<n> <input.gif> -o <output.gif> — Lossy compression for much smaller files (n = 30-200, higher = smaller).

gifsicle -O3 --lossy=80 animation.gif -o small.gif

gifsicle --colors <n> <input.gif> -o <output.gif> — Reduce color palette (2-256 colors).

gifsicle --colors 64 animation.gif -o reduced.gif

gifsicle --color-method median-cut --colors <n> <input.gif> -o <output.gif> — Reduce colors using median-cut algorithm (better quality).

gifsicle --color-method median-cut --colors 128 animation.gif -o reduced.gif

gifsicle -O3 --lossy=80 --colors 128 <input.gif> -o <output.gif> — Combine lossy compression with color reduction for maximum savings.

gifsicle -O3 --lossy=80 --colors 128 animation.gif -o tiny.gif

Resize & Crop

gifsicle --resize <width>x<height> <input.gif> -o <output.gif> — Resize to exact dimensions.

gifsicle --resize 320x240 animation.gif -o small.gif

gifsicle --resize-fit <width>x<height> <input.gif> -o <output.gif> — Resize to fit within dimensions (maintains aspect ratio).

gifsicle --resize-fit 400x300 animation.gif -o fitted.gif

gifsicle --resize-width <width> <input.gif> -o <output.gif> — Resize to specific width (auto height).

gifsicle --resize-width 320 animation.gif -o resized.gif

gifsicle --resize-height <height> <input.gif> -o <output.gif> — Resize to specific height (auto width).

gifsicle --resize-height 200 animation.gif -o resized.gif

gifsicle --scale <factor> <input.gif> -o <output.gif> — Scale by a factor (e.g., 0.5 for half size).

gifsicle --scale 0.5 animation.gif -o half.gif

gifsicle --crop <x>,<y>+<width>x<height> <input.gif> -o <output.gif> — Crop a region from the animation.

gifsicle --crop 10,10+200x150 animation.gif -o cropped.gif

gifsicle --crop-transparency <input.gif> -o <output.gif> — Remove transparent borders around the image.

gifsicle --crop-transparency animation.gif -o trimmed.gif

Frame Manipulation

gifsicle <input.gif> '#0-9' -o <output.gif> — Extract a range of frames.

gifsicle animation.gif '#0-9' -o first10.gif

gifsicle <input.gif> '#0' '#2' '#4' -o <output.gif> — Extract specific frames.

gifsicle animation.gif '#0' '#5' '#10' -o selected.gif

gifsicle --delete '#<n>' <input.gif> -o <output.gif> — Delete a specific frame.

gifsicle --delete '#0' animation.gif -o no-first.gif

gifsicle --delete '#<start>-<end>' <input.gif> -o <output.gif> — Delete a range of frames.

gifsicle --delete '#5-10' animation.gif -o shorter.gif

gifsicle <a.gif> <b.gif> -o <output.gif> — Concatenate two animations.

gifsicle intro.gif main.gif -o combined.gif

gifsicle --merge <a.gif> <b.gif> -o <output.gif> — Merge frames from multiple GIFs into one animation.

gifsicle --merge part1.gif part2.gif part3.gif -o full.gif

gifsicle --reverse <input.gif> -o <output.gif> — Reverse the frame order (play backwards).

gifsicle --reverse animation.gif -o reversed.gif

Timing & Looping

gifsicle --delay <ticks> <input.gif> -o <output.gif> — Set delay for all frames (in 1/100 second).

gifsicle --delay 10 animation.gif -o fast.gif

gifsicle '#0' --delay <ticks> '#1-' <input.gif> -o <output.gif> — Set different delay for first frame vs rest.

gifsicle animation.gif '#0' --delay 100 '#1-' --delay 5 -o custom.gif

gifsicle --loopcount=<n> <input.gif> -o <output.gif> — Set loop count (0 = infinite, 1 = play once).

gifsicle --loopcount=0 animation.gif -o looping.gif

gifsicle --no-loopcount <input.gif> -o <output.gif> — Remove looping (play once and stop).

gifsicle --no-loopcount animation.gif -o once.gif

Transform

gifsicle --rotate-90 <input.gif> -o <output.gif> — Rotate 90 degrees clockwise.

gifsicle --rotate-90 animation.gif -o rotated.gif

gifsicle --rotate-180 <input.gif> -o <output.gif> — Rotate 180 degrees.

gifsicle --rotate-180 animation.gif -o flipped.gif

gifsicle --rotate-270 <input.gif> -o <output.gif> — Rotate 270 degrees (90 counter-clockwise).

gifsicle --rotate-270 animation.gif -o rotated.gif

gifsicle --flip-horizontal <input.gif> -o <output.gif> — Mirror horizontally.

gifsicle --flip-horizontal animation.gif -o mirrored.gif

gifsicle --flip-vertical <input.gif> -o <output.gif> — Mirror vertically.

gifsicle --flip-vertical animation.gif -o flipped.gif

Common Patterns

gifsicle -O3 --lossy=80 --resize-fit 480x360 --colors 128 <input.gif> -o <output.gif> — Optimize for web: resize, reduce colors, lossy compression.

gifsicle -O3 --lossy=80 --resize-fit 480x360 --colors 128 large.gif -o web.gif

gifsicle -b -O3 *.gif — Batch optimize all GIFs in-place (-b = replace originals).

gifsicle -b -O3 *.gif

gifsicle <input.gif> '#0-' '#-2-1' -o <output.gif> — Create a ping-pong (boomerang) loop.

gifsicle animation.gif '#0-' '#-2-1' -o boomerang.gif

convert -delay 10 frames/*.png gif:- | gifsicle -O3 --lossy=80 -o <output.gif> — Create optimized GIF from PNG frames (ImageMagick + gifsicle pipeline).

convert -delay 10 frames/*.png gif:- | gifsicle -O3 --lossy=80 -o animation.gif

Conclusion

gifsicle belongs in every toolbox when animated GIFs need to be small and fast – for everyday work, -O3, --colors and --lossy combined with --resize-fit usually do the job. Bear in mind that --lossy discards image data irreversibly, and quality degrades visibly at high values. The real footgun is --batch (-b): it writes the result straight back into the original file, so a bad run cannot be undone. When in doubt, always work with a separate output file (-o) or a backup, and check the result before you replace any originals.

Further Reading

  • convert – ImageMagick tool for converting and editing images
  • optipng – lossless PNG optimizer
  • pngquant – lossy PNG compression with palette reduction