我通过一些代码,我就发现GitHub阅读(见下面的代码片段)关于获得使用PIL从EXIF的经度和纬度。除了TAGS.get(标签,标签)之外,我大多可以关注发生的事情。当我回顾Pillow reference material,它给出了一个例子,但还不足以让我知道什么代码在拉动或为什么代码有两个“标签”可变因素表明,如(标签,标签)。如果有人能够解释这个问题或提供更详细的参考资料的链接,将非常感激。Python的PIL.ExifTags - 不知道它是所有关于
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
if decoded == "GPSInfo":
gps_data = {}
for t in value:
sub_decoded = GPSTAGS.get(t, t)
gps_data[sub_decoded] = value[t]
exif_data[decoded] = gps_data
else:
exif_data[decoded] = value