Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
remove every second frame of GIF with gifsicle
#!/bin/bash
# This script will take an animated GIF and delete every other frame
# Accepts two parameters: input file and output file
# Usage: ./<scriptfilename> input.gif output.gif
# Make a copy of the file
cp $1 $2
echo "copy completed"
# Get the number of frames
numframes=`gifsicle $1 -I | grep -P "\d+ images" --only-matching | grep "[0-9][0-9]*" --only-matching`
echo "numframes completed"
# Deletion
gifsicle "$1" --unoptimize $(seq -f "#%g" 0 2 $numframes) -O2 -o "$2"
echo "script completed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.