Gallery2 plugin – displaying googlemaps with GPS coordinates from EXIF

After resuming my geotaggin script (see this post), I decided to do something useful with it. We’re using gallery2 to store our photos and with a [googlemap plugin](http://codex.gallery2.org/index.php/Gallery2:Modules:Map), but found it useful only for displaying a single pointer per album (see [here](http://gallery.ibao.net/Map/)). For a more fine-grained selection we needed something else.

Therefore, I decided to write my own plugin (yeah, there are already two out there, why not write my own? ;-) ) and also learn Gallery2 API. The idea is to display a google map at the bottom of each photo, showing exactly where the photo was taken. Yes, it photo-specific and there’s only one pointer on the map. I find it nonetheless very useful.

Here’s a [sample output](http://gallery.ibao.net/travel/Switzerland/melchsee/IMG_2991.JPG.html) (you can also admire the beautiful scenery of Melchsee ;-) ). The plugin adds a new “block” in the template (therefore can be configured using a standard block management tool in Gallery2).

The position of the current photo is always in the middle (although you can move the map around, change the map type, zoom in and out etc.). The changes you make are stored as session cookies, and preserved between consecutive photo loads. Also, the whole panel can be hidden to speed up load and only shown on demand (show map|hide map).

Any comments? suggestions? ideas?

The plugin is currently in _alpha_ stage, I will release it in a week or two (I want to create a webpage for it as well). In the meantime, if you’re interested in trying it out, drop me a line ;-)

BTW: I also found out that when iPhoto edits a photo, it converts Exif from Intel to Motorola (little endian -> big endian). There was a bug in [exifer](http://www.offsky.com/software/exif/index.php) used in gallery, which corrpted the tags. The patch is only two lines long and can be found here (I also emailed the author):

--- gps.inc.orig        2006-08-31 10:25:27.000000000 +0200
+++ gps.inc     2006-08-31 10:36:37.000000000 +0200
@@ -116,13 +116,24 @@
                        $minutes = GPSRational(substr($data,16,16),$intel);
                        $hour = GPSRational(substr($data,32,16),$intel);

+      /* now we need a hack, since the whole data has been flipped in :103
+                        * the order here is sec:min:hour. However, in the motorla mode the data
+                        * has not been flipped and the order is h:m:s. This breaks compatibility
+                        * with Motorola exif. (Tadek) */
+      if($intel==1)
                        $data = $hour+$minutes/60+$seconds/3600;
+                       else
+                                       $data = $seconds+$minutes/60+$hour/3600;
                } else if($tag=="0007") { //Time
                        $seconds = GPSRational(substr($data,0,16),$intel);
                        $minutes = GPSRational(substr($data,16,16),$intel);
                        $hour = GPSRational(substr($data,32,16),$intel);

+                       /* I guess the same HACK as above. Tadek */
+                       if ($intel==1)
                        $data = $hour.":".$minutes.":".$seconds;
+                       else
+                                 $data = $seconds.":".$minutes.":".$hour;
                } else {
                        if($bottom!=0) $data=$top/$bottom;
                        else if($top==0) $data = 0;

7 Responses to “Gallery2 plugin – displaying googlemaps with GPS coordinates from EXIF”

  1. Tadek’s Blog » Blog Archive » GeoTagging in EXIF (resumed) Says:

    [...] Tadek’s Blog Some random notes about computers, security, cool links and others. « Goodbye IBM, welcome Google Gallery2 plugin – displaying googlemaps with GPS coordinates from EXIF » [...]

  2. muesli Says:

    do it, release it! :-) sounds interesting and i just got my gps receiver today…

    looking forward to it,
    muesli

  3. Kevin Says:

    This looks fantastic – I look forward to the release – would be great to use it to display my holiday snaps next month :)

  4. Even the wrong words seem to rhyme » Blog Archive » Geo-tagging the universe, one step at a time… Says:

    [...] Finally, all of these photos can tie into Gallery (which is what I’ll be doing) using the existing Google Maps Module, or watch this space on Tadek’s blog, for a module to view locations on single images. [...]

  5. Hennie Says:

    Nicest would be to open an album and have a map with placemarkers for all photos then click a placemarker and see the photo in the same screen
    am experimenting with the maps module but this is not at all using the allready avaulable geotag info from exif in my jpeg files

    I am looking forward to you publishing this!

  6. Fable Says:

    It sounds great !!! Well, i’d like to try it. And compliments for your pictures. I live near Switzerland but….i’ve never been in such wonderful places ;(

  7. anna Says:

    did you ever release this? also, the theme listed on your gallery appears to point to the blog postings of your photo partner in crime, and the links appear…empty!

Leave a Reply