Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active November 28, 2015 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/6180396e13381a646cf3 to your computer and use it in GitHub Desktop.
Save zeffii/6180396e13381a646cf3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage:
#
# to output an large optimized gif 10 fps
# > bash gifbatch.sh /home/zeffii/Videos/braindead/
#
# to output an --color 256 optimized gif 10 fps
# > bash gifbatch.sh /home/zeffii/Videos/braindead/ 256
#
# to output an --color 256 optimized gif 24 fps
# > bash gifbatch.sh /home/zeffii/Videos/braindead/ 256 24
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit
fi
if [ $# -gt 0 ]; then
mypath=$1
fi
pushd $mypath
pwd
if [ $# -eq 1 ]; then
convert -delay 10 -loop 0 *png animated.gif &&
gifsicle -O animated.gif > opt_animated.gif
fi
if [ $# -eq 2 ]; then
colors=$2
convert -delay 10 -loop 0 *png animated.gif &&
gifsicle -O --colors $colors animated.gif > "opt_${colors}_animated.gif"
fi
if [ $# -eq 3 ]; then
colors=$2
framerate=$3
convert -delay $framerate -loop 0 *png animated.gif &&
gifsicle -O --colors $colors animated.gif > "opt_${colors}_animated_${framerate}fps.gif"
fi
popd
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment