#!/bin/bash

if [ $# -ne 2 ]
then
    echo "NeoLemmix PNG to GIF anim"
    echo "Usage: $0 32x40 yourfile.png"
    echo "First argument is resolution of input image, second is filename."
    exit
fi

TMPDIR="/tmp/neolemmixgif"

rm -rf "${TMPDIR}"
mkdir "${TMPDIR}"
convert "$2" -crop "$1" +repage +adjoin "/tmp/neolemmixgif/output_%03d.gif"
gifsicle -d 10 "${TMPDIR}/output_"* > "$2".gif
rm -rf "${TMPDIR}"
