Archives page

Posts Tagged ‘mashup’

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.

Twitter – Conversation in the Machine

It’s another of those life-changing technologies which will not only improve the way you interact your fellow humans across the planet, but also shape and change the web as we know it for a brighter future beyond our current limited borders.

No it’s not.

It’s a micro-blogging tool which performs about the same function as your Facebook status, with a bit more history and more conversation potential than real speaking. It also falls into the category of “shiny web things” that the magpie’s of the Internet world run bounding towards with wings flapping, declaring their undying allegiance and overwhelming excitement about the grand new era of technology, society and communication.

I am said magpie. I just haven’t had much use for it, so whilst most people are bounding towards Pownce with their wings wide open, I’m still trying to find an excuse.

My Twitter feed is decidedly empty, having originally opened it as a way only of updating my Facebook status before I realised that was syndication for the sake of it (See integrations with BrightKite, Loopt, and Flickr integration for reference). But I do get a kick out of things like the Tower Bridge Tweets. The wonderful thing about this Web 2.0 stuff is that you don’t have to use any of it for what it was intended for (which is usually so vague and fluffy, it only really starts to take shape after the rules have been broken).

So I grabbed a copy of the Net::Twitter module for Perl and before you know it, my script that monitors if the Wifi connection on the Blakepics server had gone down was happily tweeting away with only three more lines of (my) code.

use Net::Twitter;
my $twit = Net::Twitter->new(username=>"username", password=>"password", source => "DowntimeMonitor" );
$twit->update("Internet connection ".($state ? "is now up" : "has been restarted"));