Gifsicle is a command-line tool for creating, editing, and getting information about GIF images and animations.
# Resize animated gif by scaling down 50%:
gifsicle --scale 0.5 -i animation.gif > animation-smaller.gif
# Resize animated gif to scaling to a given width with unspecified height:
gifsicle --resize-fit-width 300 -i animation.gif > animation-300px.gif
# Resize animated gif by scaling to a given height with unspecified width:
gifsicle --resize-fit-height 100 -i animation.gif > animation-100px.gif
# Resize animated gif clipping to size:
gifsicle --resize 300x200 -i animation.gif > animation-clipped.gif
# Gifsicle has three types of GIF optimization to choose from:
# -O1 - stores only the changed portion of each image. this is the default.
# -O2 - also uses transparency to shrink the file further.
# -O3 - try several optimization methods (usually slower, sometimes better results).
# - http://davidwalsh.name/optimize-gifs
gifsicle -O3 animation.gif -o animation-optimized.gif
# ---
# To optimise a GIF:
gifsicle --batch --optimize=3 <amin.gif>
# To make a GIF animation with gifsicle:
gifsicle --delay=<10> --loop *.gif > <anim.gif>
# To extract frames from an animation:
gifsicle <anim.gif> '#0' > <firstframe.gif>
# To you can also edit animations by replacing, deleting, or inserting frames:
gifsicle -b <anim.gif> --replace '#0' <new.gif>