Bright Ideas II: Photo Tagging

I use a mix of photo gallery software, I use Flickr for some things, notable stuff that’s public for other people to use, I also use Fuzzy Monkey‘s My Photo Gallery, which is simple, but has some neat features (like auto thumbnail generation, keeps photos and thumbnails seperate, allowing me to use Unison/rsync to keep my online photos in sync with an offline copy, simple passwording etc).

But I’m beginning to dig tagging, so I hoked about for some web gallery software that does this, and there seems to be a real shortage, I found Original and a modification of it that supports tagging, but it mix of php & python, and I couldn’t get my head round all of the Python.

So this got me thinking about what is the best way to generically tag my photos so that the will work in my online gallery and with my offline tools. Microsoft have added a couple of tags in the EXIF standard, eg XPKeywords. There is some stuff on XMP, Extensible Metadata Platform from Adobe. IPTC gets mentioned quite a bit, and is also supported by Google’s latest incarnation of Picasa, but is supposedly being phased out in favour of XMP.

Notably all of this is support by Phil Harvey’s ExifTool, which is a Perl library and CLI tool.
All of this comes under metadata, i.e. it’s data about the images. So, where to start? Well, I think I need to do the following:

  • Decide which format to support! (EXIF XPKeywords, XMP, IPTC etc)
    (actually, the gallery should probably support multiple methods, but let’s try and focus on one to start with)
  • Extend My Photo Gallery so that it can scan it’s directory of photo data & build a tag database
  • Extend My Photo Gallery so that is can generate a tag cloud.
  • Extend My Photo Gallery so that it can manage tags in the management UI.

Easy eh?

Where to start? Minimal overhead to start with, probably use SQLite for the tag/photo database, make it scan photos for tags, then work on building a tag cloud. jbrout looks like the thing to start tagging with. Then add tag management to the web UI.
Here’s some of my background reading:

Unison, Cygwin & syncing stuff

I have a Linux VPS account which I use for hosting this and some private photo collections [i.e. personal, not porn!] etc, I used to use Unison to sync my photo directories between my Linux VPS and my Linux Laptop. I’m currently running Windows XP on my laptop, so I was looking for a way of syncing stuff with my off site storage again, after some playing around with different versions of Unison, I settled on running unison from withing Cygwin. I have a bash script that fixes the permissions on the remote filesystem and some other stuff using SSH. Getting ssh-agent to work cleanly in a Cygwin environment is tricky, I found the following tips, and liked this one. It needed some tweaking to work, probably just the knock on effect of having spaces in my $HOME.

This fragment can be used to setup the ssh-agent so that the rest of the commands in the script that use SSH don’t prompt for passphrases (including running unison using ssh)
[quickcode:noclick]
#
# Setup ssh-agent if it’s not already there
# This is where the ssh-agent environment settings are stored for scripts
# using this fragment
SSH_ENV=”$HOME/.ssh/environment”
function start_agent {
echo “Initialising new SSH agent…”
/usr/bin/ssh-agent | sed ‘s/^echo/#echo/’ > “${SSH_ENV}”
echo succeeded
chmod 600 “${SSH_ENV}”
. “${SSH_ENV}” > /dev/null
/usr/bin/ssh-add;
}

# Source SSH settings, if they are there
if [ -f “${SSH_ENV}” ]; then
. “${SSH_ENV}” > /dev/null
# If ssh-agent is dead or gone, start from scratch
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || {
start_agent;
}
else
# start from scratch
start_agent;
fi
[/quickcode]

After this script, I just call ssh a couple of times to tidy up the remote destination, and then call unison using a profile that also uses ssh, slicker than a greased monkey falling of a pole.

Joel does it again

Joel Spolsky has an excellent set of brief articles on management styles in IT (focused on software developement, but I believe the comments apply across the board for creative technology[1] roles)

They are as follows:

Worth a read if your management or managed. I work with several ex-military people, where we have a mix of C&C and measurement…I’m still mulling over what that means 🙂

[1] Technology workers split into 2 camps, those of us who design, implement & maintain any kind of IT system and the end users. I’m focusing on the former, but end users shouldn’t be devoid of creative thought, they are the actual users of systems we create.

Cut & Shut (I’ve moved to WordPress from Movable Type)

A couple of friends have just started blogging (Keith & Jonny), I was stunned how clean and simple their blogs look. At the same time I’ve been getting frustrated at several things in MovableType (like the lack of any decent online editing tools for creating posts, and the fact that it is painfully slow on my VPS), so I had a quick look at the blogging software they are using, WordPress. I was mightly impressed, it seems to be much slicker & easier to use than MT, I was even more impressed that I could import all my current entries & comments, and that there’s plenty of help in making old links work. So I exported my stuff from MT & imported into WordPress, with the help of notes from here. I’ve also got over my need for everything to be in perl.

The next challenge was to ensure that old links get redirected to the content properly, this was mostly just a technical challenge as this blog is mostly private, I doubt anybody I don’t know reads it, so ensuring that links in search engine indexes is largely moot. (I had to struggle to find a reference to my blog in Google, resorting to restricting it to my site, like this). Anyway, I found a couple of pointers that sent me in the right direction, like one from the WordPress wiki and one from the newer Codex resource.

I ran into some snags in the method used here, mostly because the permalink/archive method I had used in MT was YYYY/MM/entry, so here’s the template I needed:

<?php
require('wp-config.php');
header('Content-type: text/plain');
?>
<MTEntries lastn="999999">
Redirect Permanent /archives/<$MTArchiveDate format="%Y/%m"$>/<MTArchiveFile>
http://www.mccartney.ie/wordpress/<$MTArchiveDate format="%Y/%m/%d"$>/<?php echo sanitize_title("<$MTEntryTitle$>"); ?></MTEntries>

This generates a file that us suitable for using as a .htaccess file, making Apache redirect requests for the old MT URIs to the new WordPress URIs. For the category links, I’ve just hand crafted the lines, I only had a couple of categories.

(In writing this post, I’ve discovered some of the problems with quoting PHP in a PHP based system, so I’ve started to read this and promise to make the template above make sense soon, I also found this) Done.