Source

flickr-badge / mkflickrbadge.sh

Full commit
#!/bin/sh

if [ $# -ne 3 ] ; then
	echo usage: mkbadge username geometry output.png
	exit -1
fi

username=$1
geometry=$2
output=$3

export geometry
N=$((`echo $geometry|sed 's/x/*/'`))

tmpdir=$(mktemp -d /tmp/flckXXXXXXXX)
urls="$tmpdir/urls"
outbasename=$(basename "$output")

flickrlatest.py "$username" $N | tac > "$urls"

if [ -s "$urls" ] ; then
	( \
		cd "$tmpdir" && \
		wget -q -i "$urls" && \
		gm montage -tile $geometry -quality 95 -background black \
			-geometry 75x75\> $(ls -r *_s.jpg) "$outbasename" \
	) && \
	cp "$tmpdir/$outbasename" "$output"
fi

rm -rf $tmpdir