I wrote this program `ulf` so I would have an easy way to upload
photos to my web site. The procedure goes like this:

1. Take the photo with the camera.
2. Plug the camera into the computer.
3. Type at a command prompt:

        $ ulf cute_kitten.jpg

4. Close the window showing the picture that will be uploaded.
5. Paste the output URL into an appropriate place (e.g. Facebook,

For someone else to use this program, they would probably have to
tweak the paths a bit.

Note that I `set -e` early on in the script and use double quotes
around every variable expansion. I find that these things make
programming in the shell mildly less error-prone.

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


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

    [ ! -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";

This software is available via

    git clone http://canonical.org/~kragen/sw/inexorable-misc.git

(or in <http://canonical.org/~kragen/sw/inexorable-misc>) in the file

Like everything else posted to kragen-hacks without a notice to the
contrary, this software is in the public domain.

To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-hacks

Reply via email to