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.gifgifsicle -I <input.gif> — Display information about a GIF (frames, dimensions, colors).
gifsicle -I animation.gifgifsicle --info --color-info <input.gif> — Show detailed info including color table and frame data.
gifsicle --info --color-info animation.gifgifsicle --explode <input.gif> — Extract all frames as individual GIF files.
gifsicle --explode animation.gifgifsicle <input.gif> '#0' -o <output.gif> — Extract a single frame (0-indexed).
gifsicle animation.gif '#0' -o first-frame.gifOptimization
gifsicle -O3 <input.gif> -o <output.gif> — Maximum optimization (best compression, slowest).
gifsicle -O3 animation.gif -o optimized.gifgifsicle -O2 <input.gif> -o <output.gif> — Standard optimization (good balance of speed and size).
gifsicle -O2 animation.gif -o optimized.gifgifsicle -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.gifgifsicle --colors <n> <input.gif> -o <output.gif> — Reduce color palette (2-256 colors).
gifsicle --colors 64 animation.gif -o reduced.gifgifsicle --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.gifgifsicle -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.gifResize & Crop
gifsicle --resize <width>x<height> <input.gif> -o <output.gif> — Resize to exact dimensions.
gifsicle --resize 320x240 animation.gif -o small.gifgifsicle --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.gifgifsicle --resize-width <width> <input.gif> -o <output.gif> — Resize to specific width (auto height).
gifsicle --resize-width 320 animation.gif -o resized.gifgifsicle --resize-height <height> <input.gif> -o <output.gif> — Resize to specific height (auto width).
gifsicle --resize-height 200 animation.gif -o resized.gifgifsicle --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.gifgifsicle --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.gifgifsicle --crop-transparency <input.gif> -o <output.gif> — Remove transparent borders around the image.
gifsicle --crop-transparency animation.gif -o trimmed.gifFrame Manipulation
gifsicle <input.gif> '#0-9' -o <output.gif> — Extract a range of frames.
gifsicle animation.gif '#0-9' -o first10.gifgifsicle <input.gif> '#0' '#2' '#4' -o <output.gif> — Extract specific frames.
gifsicle animation.gif '#0' '#5' '#10' -o selected.gifgifsicle --delete '#<n>' <input.gif> -o <output.gif> — Delete a specific frame.
gifsicle --delete '#0' animation.gif -o no-first.gifgifsicle --delete '#<start>-<end>' <input.gif> -o <output.gif> — Delete a range of frames.
gifsicle --delete '#5-10' animation.gif -o shorter.gifgifsicle <a.gif> <b.gif> -o <output.gif> — Concatenate two animations.
gifsicle intro.gif main.gif -o combined.gifgifsicle --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.gifgifsicle --reverse <input.gif> -o <output.gif> — Reverse the frame order (play backwards).
gifsicle --reverse animation.gif -o reversed.gifTiming & 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.gifgifsicle '#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.gifgifsicle --loopcount=<n> <input.gif> -o <output.gif> — Set loop count (0 = infinite, 1 = play once).
gifsicle --loopcount=0 animation.gif -o looping.gifgifsicle --no-loopcount <input.gif> -o <output.gif> — Remove looping (play once and stop).
gifsicle --no-loopcount animation.gif -o once.gifTransform
gifsicle --rotate-90 <input.gif> -o <output.gif> — Rotate 90 degrees clockwise.
gifsicle --rotate-90 animation.gif -o rotated.gifgifsicle --rotate-180 <input.gif> -o <output.gif> — Rotate 180 degrees.
gifsicle --rotate-180 animation.gif -o flipped.gifgifsicle --rotate-270 <input.gif> -o <output.gif> — Rotate 270 degrees (90 counter-clockwise).
gifsicle --rotate-270 animation.gif -o rotated.gifgifsicle --flip-horizontal <input.gif> -o <output.gif> — Mirror horizontally.
gifsicle --flip-horizontal animation.gif -o mirrored.gifgifsicle --flip-vertical <input.gif> -o <output.gif> — Mirror vertically.
gifsicle --flip-vertical animation.gif -o flipped.gifCommon 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.gifgifsicle -b -O3 *.gif — Batch optimize all GIFs in-place (-b = replace originals).
gifsicle -b -O3 *.gifgifsicle <input.gif> '#0-' '#-2-1' -o <output.gif> — Create a ping-pong (boomerang) loop.
gifsicle animation.gif '#0-' '#-2-1' -o boomerang.gifconvert -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
- gifsicle – official project page (LCDF) – downloads, documentation and background on the tool
- gifsicle manual (man page) – complete reference of all options and frame selectors