Skip to content

Instantly share code, notes, and snippets.

@dijeferson
Created July 7, 2014 14:51
Show Gist options
  • Save dijeferson/b7ac596c8467a9c6d3a0 to your computer and use it in GitHub Desktop.
Save dijeferson/b7ac596c8467a9c6d3a0 to your computer and use it in GitHub Desktop.
Map photos using exif data
import photos
import webbrowser
query = 'safari-http://maps.apple.com/?q=%s,%s'
img = photos.pick_image(include_metadata=True)
meta = img[1]
gps = meta.get('{GPS}')
if gps:
latitude = str(gps.get('Latitude', 0.0)) + gps.get('LatitudeRef', '')
longitude =str(gps.get('Longitude', 0.0)) + gps.get('LongitudeRef', '')
print '%s, %s' % (latitude, longitude)
webbrowser.open(query % (latitude, longitude))
else:
print 'Last photo has no location metadata.'
@dijeferson
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment