#!/bin/sh
# upload last photo
set -e
outname="${1?usage: $0 foo.jpg}"

dir=/media/CANON_DC/dcim/102canon

[ -d "$dir" ]
lastphoto=$(ls -t "$dir" | head -1)

tmpdir="$HOME/tmp"
[ ! -f "$tmpdir/$lastphoto" ]
mv "$dir/$lastphoto" "$tmpdir"/.

# Is it portrait-mode and therefore to be rotated? How can I tell?
# Which way do I rotate it? Fuck it, I’ll just rotate it on the
# server...
# mogrify -rotate 90 foo.jpg

convert -scale 1024x768 "$tmpdir/$lastphoto" "$tmpdir/$outname"
eog "$tmpdir/$outname" &
scp "$tmpdir/$outname" panacea.canonical.org:public_html/tmp/.
echo "http://canonical.org/~kragen/tmp/$outname"
