Sunday 26 October 2008

Adding GPS track data to JPG exif data




Recently I went on holiday with my girlfriend, my little olympus digital snappy camera, and my nokia E71 phone.


While touring Paris, I left the E71 (with built-in GPS) running Nokia's SportsTracker software, which is quite a respectable GPS tracking tool. Naturally, I also took more than a few photos.

Just before starting the SportsTracker session, I ensured that my camera and phone times were more-or-less in sync.

Various web-based photo sites allow one to see where a photo was taken by using the GPS coordinates in the JPG Exif data, and I rather liked the idea of being able to see a map displaying the photos I've taken. I'm specifically thinking about google's picasaweb here, but they're not the only one. For example: http://picasaweb.google.com/karl.dane/Testing?authkey=6ER8sJ42S90#5260750179838664114

Now, some weeks later, I have the data that SportsTracker recorded, and a load of photos. The problem was how to merge the two. Well - I'm a perl coder, so that seemed to be the sensible approach.

SportsTracker will export to various formats, and of these XML seemed the most useful. This was where I learned just how limited XML::Simple is; the XML file produced by SportsTracker was about 4.6MB, and to turn this into a perl data structure took about 20 minutes!


XML::libXML seemed the way to go, but it looked reasonably scary. Thankfully, I found a splendid page 'Stepping up from XML::Simple to XML::libXML' which provided the necessary examples: http://www.perlmonks.org/index.pl?node_id=490846


All that remained was to find a good exif editing utility, and Exiftool seemed to be perfect: http://freshmeat.net/projects/exiftool

So - the script I wrote looks at a directory of JPEGs and uses exiftool to lookup the original creation time of each image.

It then hunts through the XML file for a timestamp that closely matches that of the jpeg. When found, it pulls out the appropriate coordinates, and uses Exiftool again to update the file accordingly.

It's a little on the slow side; there are definitely areas for improvement / efficiency gains, but it does the job.

Obviously this is tuned to work for SportsTracker XML exports, but it should be quite easy to adapt to any other XML format.

Find the script here: gps-exif.pl

Requires Date::Manip, XML::libXML and Exiftool

Must pass -d switch to tell it where your photos are
, and -x to tell it which xml file to read.


Karl Dane

Olverum Bath Oil


Are you stressed and worn out? Coryzal symptoms? Or nothing to do on a Friday night? The prognosis is good with Olverum Bath Oil, the only bath oil that has fulfilled all the criteria for the perfect soak. Absolutely amazing relaxing and yet uplifting aroma, wafting out of the steamy water and soaking perfectly into the skin, with no oily residue on the bath afterwards. All muscle aches and negative thoughts are dismissed, a recipe for insomnia as well, the pillow rises to meet my head and I am instantly asleep and restored when I stumble into bed.

Read all about it and order online at www.olverum.com