Created
May 9, 2018 13:27
-
-
Save Mad182/ff0213a1f1ff3e560d5c6442c5d45fa8 to your computer and use it in GitHub Desktop.
Drop every second frame from GIF image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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