After years of procrastination and inevitable buyer's remorse, I bought a DSLR. I was really set on having a full-frame sensor, HD video and high ISO ranges (for low light shooting) so I went with the Canon 6D. One of my favorite features is the built-in GPS -- a first for Canon. When I looked at the EXIF data, I noticed the geo coordinates tagged for each photo. Since I want to post the photos along with this data on my blog at some point, I hacked up a small Jekyll plugin. The plugin will extract the EXIF data from a photo using the exifr gem into Liquid markup and converts the GPS coordinates into a physical address using the Google Maps API.

require 'exifr'
require 'open-uri'
require 'json'

module Jekyll
  class ExifTag < Liquid::Tag
    def initialize(tag_name, file, token)
      @image_file = File.expand_path "../" + file.strip , File.dirname(__FILE__)

    def render(context)
      exif = EXIFR::JPEG::new(@image_file)
      if !exif.gps.nil?
        coords = exif.gps.latitude.to_s + "," + exif.gps.longitude.to_s
        url = "http://maps.google.com/maps/api/geocode/json?latlng=#{coords}&sensor=false"
        photo_gps = JSON.parse(open(url).read)['results'][0]['formatted_address']
        photo_gps = false

Liquid::Template.register_tag('exif', Jekyll::ExifTag)

I've extended the plugin a bit further to output the HTML, pre-wrapped in a nifty div that matches the page layout. The end result looks something like this:

  <div class="panel panel-info">
    <strong>Camera</strong>: Canon EOS 6D<br>
    <strong>Focal Length</strong>: 50mm<br>
    <strong>&#402;/</strong> 1.8<br>
    <strong>ISO</strong>: 12800<br>
    <strong>Location</strong>: 12414 Short Ave, Los Angeles, CA 90066, USA