Automatically Geotagging your Gallery

Tags from Blakepics

Automatically add geonames.org tags to Gallery

As always, an imminent holiday has inspired me to update the entire system behind geotagging my photos.  Likewise, needing to plan said holiday has given me the opportunity to procrastinate and do something else instead.

Wishlist

  • A repository I can drop files created by the Genie BGT-31 GPS tracker.
  • Automatically convert the tracks into GPX format.
  • Automatically stamp any photos within Blakepics with their longitude / latitude values into the EXIF information.
  • Use that EXIF information to populate the database for the Gallery2 maps module.
  • Use geonames to get some basic tags, and automatically add those to the tags database.

I can happily report all of the above is happily running on a schedule on the Blakepics server.   Whilst I realise a lot of these options aren’t particularly available on a shared hosting server, I’m going to talk about them anyway.

A small disclaimer

Be under no illusion, a lot of these scripts are hacked together with no thought given to scalability, stability, or re-use.  They’d be a lot better off as a proper Gallery2 module to be honest – and hopefully someone will beat me to it in making that a reality.  However, for the time being – this is all provided as-is 🙂

NMEA repository

The repository is quite simple with an SFTP server running (sshd for example), and FileZilla on the client

Convert the tracks to GPX

  1. Install the rather excellent gpsbabel.
    yum install gpsbabel
  2. Run this convert-to-gpx.pl.txt perl script to combine all your nmea tracks to create a single gpx file.

Stamp the photos

  1. Get the gpsPhoto perl script.  You might find you need to install some perl modules:
    perl -eshell -MCPAN
    install modulename
  2. Use this geocode-photos.pl.txt script to find any matching photos from your Gallery, and tag them.  Note that I limit them to only photos I’ve uploaded myself, as I don’t want to go messing around with other peoples (and they were probably not at the same location anyway)

Fill the Gallery2 maps module with the EXIF data

There’s a maintenance task to use the EXIF data to power the maps module of Gallery2, so using Roel Broersma’s excellent script to run the maintenance tasks, these can be scheduled with the extra line:

wget --quiet --output-document=/dev/null --cookies=on --load-cookies $TMP_PATH/myg2cookies "$G2_URL/main.php?g2_controller=core.AdminMaintenance&g2_form%5Baction%5D%5BrunTask%5D=1&g2_taskId=PopulateGPSEXIFInfos&g2_authToken=$AUTHTOKEN"

Give some meaning to your location data with geonames

Geonames provides a reverse-lookup to get some more human readable descriptions of your photos.  So I use this to put in the country, region and town data into my Gallery.  You can go a bit further and get details of nearby landmarks from Wikipedia to add if you like, but i don’t find it too useful for my purposes.

  1. You’ll need some more perl modules
    perl -eshell -MCPAN
    install Image::ExifTool;
    install Image::ExifTool::Location;
    install Geo::GeoNames;
    install Data::Dumper;
  2. Get my write-geoname-tags.pl.txt perl script, which is actually a combination of all the previous scripts.  This will query the web service, and update your tags.

It all sounds very complicated…

Well, yes.  My aim isn’t to create the easiest system to set-up, it’s to create the easiest system to use.  Uploading a single NMEA track list now causes all of the above to happen automatically.  That said, I recognise that it’s not for the faint-hearted.

So why not try one of these easier solutions:

What next?

Add all of these scripts mentioned above to a cron task, and forget all about it.  You can probably combine the whole lot into a single job (I wanted to keep them separate, so some could be run nightly, and others weekly or monthly).

Hopefully this is the humble beginnings of a more efficient and elegant solution.  For now I’m at least getting a lot more data into and out of my photos

Do let me know if you make any improvements, or have any ideas for viable new features – I’d be interested to hear from you.

Geotagging with the Genie BGT-31

Don’t get me wrong, buying the Trackstick was a really good idea, it’s fuelled my interest in the location-aware Internet, it’s given me excuses to connect with other developers on Gallery2, had me writing geo-based modules, updates and hacks, and eased geotagging a whole bunch of photos.

But in the past two years, it’s also caused me to create and use some really really complicated geotagging techniques, frustration over forgetting what the flashing lights mean in Krakow, and aided and abetted in destroying one man’s Internet business in Split, even if just for a day.

Even the new Trackstick II’s still only boast a 1MB block of memory for storing tracks on, and I still need their proprietary drivers that caused me to destroy the book store/Internet Cafe in Split.  So for my next trip to Vietnam, I’ve bought the Genie BGT-31.  Granted, it’s almost twice the size of the Trackstick but contains a USB-chargeable battery which means no more carrying around stacks of AAA batteries and separate charger.

The built-in memory will store up to 20,000 records – but more importantly, supports SD cards, increases the measly 1MB into 1GB (thanks to the numerous cards lying around my flat and down the side of sofas).  These can taken out very quickly and dropped into the EEE where gpsbabel will convert the flat NMEA text format to whatever you might need … GPX, for example.

It also has a screen, so I no longer need to repeat the mantra constantly to myself in my head (or aloud) – “green for good, red for bad”.  Not to mention keep my blog posts updated with some more positioning (well, possibly).

So far the first impressions are good – and it will certainly tide me over until we can just tag the photos using our government-issue ID card’s weekly e-statements.

Ubuntu Eee (701) Suspend / Resume problems

Eee Ubuntu

Since installing Ubuntu on the Eee, I had no doubt it was going to replace the Xandros install full-time.  It has a lot more features for my inner geek and better support for the applications that only I can find essential.

It also takes a hell of a lot longer to boot up.

But that’s okay, these new Atom processors don’t take up a lot of battery life when they’re in standby… If I were a real reporter, I’d test that theory.  But since I’m blogging, so I’ll throw out any kinds of lies that I like – so long as I’m upfront and honest about it.

So far so good, except Resume doesn’t work on Ubuntu Eee, either.

Great.

So I followed the steps on the usual eee user wiki about suspend/resume.  And that didn’t work either.

What I did find, is that you can actually resume from the never-ending sleep of the Ubuntu if you run the command:

sudo /etc/acpi/sleep.sh force

Furthermore, you can replace the pm-suspend command with the same – and your shiny new Ubuntu Eee will wake up when you ask it.  Rather than whining about it being too early and throwing the covers over its head.
#Make a backup, just in case.
sudo cp /usr/sbin/pm-suspend /usr/sbin/pm-suspend.bak
sudo echo "/etc/acpi/sleep.sh force" >/usr/sbin/pm-suspend

And that will let you continue to use the lid or the shut-down screen for all your eee suspension needs.  Hopefully I can do something about that initial boot-time, next.

Twitter Convergence – Ten Top Twitter Tools

i twitter from my fridge

'i twitter from my fridge' … Still waiting…

Two months ago, I had no use for Twitter.  Now it seems it’s everywhere, on everything and no device can survive without that talkative little bird.  So I thought I’d gather together all the different applications I’ve managed to dig out and install so far.

  1. TwitterFeed – Update Twitter automatically from this blog – both the posts and currently reading RSS feeds.
  2. Twit4Live (MSN Live Messenger Plus!) – Update your status from within any messenger chat window with /twitter <tweet>.
  3. rss2psm Nutz (MSN Live Messenger Plus!) – A slightly modified version of this script updates my MSN Personal Message whenever I post to Twitter.
  4. Twitula (Windows Mobile enabled iPAQ 4150)
  5. Shozu (Symbian Nokia N95)
  6. Twitux (GNOME Linux / Ebuntu Eee PC 701)
  7. TwitterFox (Firefox) – Update and view status from within the browser.
  8. RSS2IMAP – My RSS feed reader of choice, read the Twitter RSS and convert into emails, for viewing in Thunderbird.
  9. Facebook Twitter – Updates my Facebook status whenever I post to twitter (from anywhere).
  10. BeTwittered (iGoogle)

And because of all of this, I never need to visit twitter.com any more.  That’s progress 🙂

Using SVN to manage your WordPress install

I use SVN to manage both this blog and the Blakepics Gallery2 installation.  Using the version control software as a means of keeping my own sites’ shared components up to date is horribly convenient once you get through the initial attempts of “shit, I’ve broken it again”.

Wordpress have full instructions for setting up your blog with SVN.  I’d recommend sticking to the ‘Tracking Stable Version’ section and controlling your upgrades rather than checking out the trunk and risking an unstable install.  This basically comes down to a single command to be run within your wwwroot.

svn co http://svn.automattic.com/wordpress/tags/2.6.2 .

When a new version is released, you can switch to that with:

svn sw http://svn.automattic.com/wordpress/tags/2.6.3

What they don’t mention, is you can do exactly the same with your plugins using the repository here…

For example, find the plugin you want, and checkout to your plugin folder:

svn co http://plugins.svn.wordpress.org/share-this/tags/2.3/ share-this

As before, you can switch to new releases (make sure you’re in that plugin directory first) with:

svn sw http://plugins.svn.wordpress.org/share-this/tags/2.3/

And should you forget the URL you’ve got it from (like when you see there’s an upgrade available, running ‘svn status’ in that directory should help you out.

Once you get the hang of it, it really saves so much more time than that slow download, unzip, copy process you’re probably all used to, and you stand a much better chance at maintaining your own modifications without rewriting them all the time 🙂