Skip to content

Instantly share code, notes, and snippets.

@quantombone
Created July 8, 2015 16:42
Show Gist options
  • Save quantombone/472ee783dfbb39320f2e to your computer and use it in GitHub Desktop.
Save quantombone/472ee783dfbb39320f2e to your computer and use it in GitHub Desktop.
Create animated gif from directory of jpeg images
#!/bin/sh
# Takes a directory of jpg images and produces an animate.gif
# Requires imagemagick's convert tool (Try apt-get install imagemagick)
#
# Tomasz Malisiewicz ([email protected])
if [ "$#" -ne 1 ]; then
echo "Usage: $0 DIRECTORY" >&2
echo "This will produce animate.gif in the current directory"
exit 1
fi
#Create a temporary directory for the gifs
GIFDIR=`mktemp -d`
echo "Producing gifs inside" ${GIFDIR}
for f in `find $1 -maxdepth 1 -name "*jpg"`; do
echo "Image $f"
convert $f ${GIFDIR}/`basename $f .jpg`.gif
done
echo "Making animate.gif"
convert -delay 20 -loop 0 ${GIFDIR}/*.gif animate.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment