Skip to content

Instantly share code, notes, and snippets.

@tylerpaige
Last active September 6, 2017 15:29
Show Gist options
  • Save tylerpaige/af4ecf59740f5316309bf4063ce39652 to your computer and use it in GitHub Desktop.
Save tylerpaige/af4ecf59740f5316309bf4063ce39652 to your computer and use it in GitHub Desktop.
Remove every n frames of gif
#!/bin/bash
# This script will remove every n frames an GIF
# Usage: ./frame-count-reduction.sh input.gif n output.gif
input=$1
divider=$2
output=$3
numOfFrames=eval gifsicle master.gif -I | grep -E -o "[0-9]+ images" | grep -E -o "[0-9]+"
numOfFramesInclusive=$((numOfFrames - 1))
gifsicle $input `
for ((a=0; a <= $numOfFramesInclusive ; a++))
do
if [ $(($a % $divider)) != 0 ]
then
echo "#$a"
fi
done
` -O3 -o $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment