I'm using exifread
to get some Exif info from photos.
Currently, I'm trying to get the GPS Latitude and Longitude, which I can do:
def main():
images = image_paths(IMAGE_FOLDER) # folder is say "Sample Photos\\"
info = {}
for img in images:
_lat, _lon = "", ""
tags = exifread.process_file(open(img,'rb'))
for i in tags.keys():
if i == "GPS GPSLatitude":
print(i, ":::", tags[i])
This prints what I expect, they key name and the values:
GPS GPSLatitude ::: [32, 52, 66443/1250]
GPS GPSLatitude ::: [32, 52, 531699/10000]
GPS GPSLatitude ::: [32, 52, 531699/10000]
GPS GPSLatitude ::: [32, 52, 132789/2500]
GPS GPSLatitude ::: [32, 52, 265817/5000]
But, to skip doing that loop and just get the key/value pairs quickly, I'm trying instead (this replaces the for i ...
loop)
_lon = tags["GPS GPSLatitude"]
But I get an error:
KeyError: 'GPS GPSLatitude'
How do I access "GPS GPSLatitude" (and "GPS GPSLongitude") without looping through the keys of tags
?
Edit:
tags
is <class 'dict'>