#!/usr/bin/env python3
# from fractions import Fraction
import sys,webbrowser,exifread
from collections import defaultdict
def convert_to_decimal(coord):
return sum(float(coord.values[i]) / (60**i) for i in(0,1,2)) # почему у sec с Fraction, а deg и min без
trans,res = defaultdict(str,dict(f"GPS GPSL{p}".split(",")for p in "atitude,lat ongitude,lon atitudeRef,lat_ref ongitudeRef,lon_ref".split()),),defaultdict(str)
with open(sys.argv[1], "rb") as file_handle: # запуск без арга(ов) словит исключение
for tag, value in exifread.process_file(file_handle).items():
if fld := trans[tag]:
res[fld] = (convert_to_decimal, str)[fld[-3:] == "ref"](value)
res["lat"] *= (-1) ** (res["lat_ref"] in ["S"])
res["lon"] *= (-1) ** (res["lon_ref"] in ["W"])
req = "https://www."+("openstreetmap.org/?mlat=%s&mlon=%s&zoom=18", "google.com/maps?q=%s,%s")[sys.argv[2:3] == ["google"]]
webbrowser.open(req % (res["lat"], res["lon"]))
#!/usr/bin/env python3
# from fractions import Fraction
import sys,webbrowser,exifread
from collections import defaultdict
def convert_to_decimal(coord):
return sum(float(coord.values[i]) / (60**i) for i in(0,1,2)) # почему у sec с Fraction, а deg и min без
res,trans =
defaultdict(int),defaultdict(str,dict(p.split(",")for p in "atitude,1 ongitude,2 atitudeRef,-1 ongitudeRef,-2".split()))
with open(sys.argv[1], "rb") as file_handle: # запуск без арга(ов) словит исключение
for tag, value in exifread.process_file(file_handle).items():
if tag.startswith("GPS GPSL")and(fld := transG[tag[8:]]) # ;)
res[fld] = (convert_to_decimal, str)[fld<0](value)
req = "https://www."+("openstreetmap.org/?mlat=%s&mlon=%s&zoom=18", "google.com/maps?q=%s,%s")[sys.argv[2:3] == ["google"]]
webbrowser.open(req % (res[i]*(-1) ** (res[-i] in ("WS"[-i])) for i in 1,2))
#!/usr/bin/env python3
# from fractions import Fraction
for p in "sys.argv webbrowser.open exifread.process_file collections.defautdict".split():
a,b=p.split('.')
globals()[p.replace(*'._')]=getattr(__import__(a),b)
def convert_to_decimal(coord):
return sum(float(coord.values[i]) / (60**i) for i in(0,1,2)) # почему у sec с Fraction, а deg и min без
res,trans =
collections_defaultdict(int),collections_defaultdict(str,dict(p.split(",")for p in "atitude,1 ongitude,2 atitudeRef,-1 ongitudeRef,-2".split()))
with open(sys_argv[1], "rb") as file_handle: # запуск без арга(ов) словит исключение
for tag, value in exifread_process_file(file_handle).items():
if tag.startswith("GPS GPSL")and(fld := transG[tag[8:]]) # ;)
res[fld] = (convert_to_decimal, str)[fld<0](value)
req = "https://www."+("openstreetmap.org/?mlat=%s&mlon=%s&zoom=18", "google.com/maps?q=%s,%s")[sys.argv[2:3] == ["google"]]
webbrowser_open(req % (res[i]*(-1) ** (res[-i] in ("WS"[-i])) for i in 1,2))
Всякие брейвы, вивальди, zen броузеры и librewolf’ы, те то что популярно у линуксоидов в отличии от хромиумов/фаерфоксов с анальными зондами, всегда запускаются через xdg-open