Skip to content

Instantly share code, notes, and snippets.

@bvenable
Last active April 28, 2016 21:16
Show Gist options
  • Save bvenable/cf9f6405c5162eac310dc2696064dcca to your computer and use it in GitHub Desktop.
Save bvenable/cf9f6405c5162eac310dc2696064dcca to your computer and use it in GitHub Desktop.
#!/bin/bash
rand ()
{
RANGE=$1;
number=$RANDOM;
let "number %= $RANGE";
let "number = $number + 1"
}
PICRANGE=$(ls pics/* 2>/dev/null | wc -l)
QUOTERANGE=$(ls quotes/* 2>/dev/null | wc -l)
if [ $PICRANGE -lt 1 ]; then
2>&1 echo "no pictures found"
exit 1
fi
if [ $QUOTERANGE -lt 1 ]; then
2>&1 echo "no quotes found"
exit 1
fi
PICNUM=$(rand $PICRANGE)
QUOTENUM=$(rand $QUOTERANGE)
PIC=$(ls pics/* | head -${PICNUM} | tail -1)
QUOTE=$(ls quotes/* | head -${QUOTENUM} | tail -1)
width=$(identify -format %w ${PIC})
let "width = $width - 10"
if [ -n "$1" ]; then
OUTPUT=$1
else
OUTPUT=random.gif
fi
convert ${PIC} -gravity center -background white -alpha remove -size ${width}x caption:@${QUOTE} -append $OUTPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment