Current code:
#!/usr/bin/env python3
import sys
from fractions import Fraction
import webbrowser
import exifread
def convert_to_decimal(coord):
deg = float(coord.values[0])
min = float(coord.values[1]) / 60
sec = float(Fraction(coord.values[2])) / 3600
return deg + min + sec
with open(sys.argv[1], 'rb') as file_handle:
tags = exifread.process_file(file_handle)
for tag, value in tags.items():
if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
if tag == 'GPS GPSLatitude':
lat = value
if tag == 'GPS GPSLongitude':
lon = value
if tag == 'GPS GPSLatitudeRef':
lat_ref = str(value)
if tag == 'GPS GPSLongitudeRef':
lon_ref = str(value)
lat_dec = convert_to_decimal(lat)
lon_dec = convert_to_decimal(lon)
if lat_ref in ['S']:
lat_dec = -lat_dec
if lon_ref in ['W']:
lon_dec = -lon_dec
webbrowser.open(f'https://www.openstreetmap.org/?mlat={lat_dec}&mlon={lon_dec}&zoom=18')
Also created the upstream issue to integrate something like this EXIF: coords latitude/longitude: please add a clickable link to OpenStreetMap (#353) · Issues · GNOME / gThumb · GitLab