我通過一些代碼,我就發現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