Skip to content

Instantly share code, notes, and snippets.

@Mad182
Created May 9, 2018 13:27
Show Gist options
  • Save Mad182/ff0213a1f1ff3e560d5c6442c5d45fa8 to your computer and use it in GitHub Desktop.
Save Mad182/ff0213a1f1ff3e560d5c6442c5d45fa8 to your computer and use it in GitHub Desktop.
Drop every second frame from GIF image
#!/bin/bash
# Drop every second frame from GIF image,
# using the same process as https://ezgif.com/optimize
#
# usage:
# frame_drop.sh in.gif out.gif
numframes=`gifsicle $1 -I | grep -P "\d+ images" --only-matching | grep -P "\d+" --only-matching`
frames=`expr $numframes - 1`
convert $1 -coalesce $2.tmp.gif
gifsicle $2.tmp.gif --delete `seq -f "#%g" 0 2 $frames` -O2 -o $2
rm $2.tmp.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment