Skip to content

Instantly share code, notes, and snippets.

@mmb
Created March 26, 2009 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmb/86400 to your computer and use it in GitHub Desktop.
Save mmb/86400 to your computer and use it in GitHub Desktop.
get latitude and longitude from a photo
#!/usr/bin/ruby
# get latitude and longitude from a photo
# known to work with iphone photots
require 'rubygems'
require 'exifr'
x = EXIFR::JPEG.new(ARGV[0])
lat = x.gps_latitude
lon = x.gps_longitude
unless lat.nil? or lon.nil?
lat = lat[0] + lat[1] / 60.0 + lat[2] / 3600.0
lon = lon[0] + lon[1] / 60.0 + lon[2] / 3600.0
lat *= -1 if x.gps_longitude_ref == 'S'
lon *= -1 if x.gps_longitude_ref == 'W'
puts "http://maps.google.com/maps?q=#{lat},#{lon}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment