📜  使用 pil 加载图像元数据 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:29.798000             🧑  作者: Mango

代码示例1
import PIL.Image
img = PIL.Image.open('img.jpg')
exif_data = img._getexif()

# iterating over all EXIF data fields
for tag_id in exif_data:
    # get the tag name, instead of human unreadable tag id
    tag = TAGS.get(tag_id, tag_id)
    data = exifdata.get(tag_id)
    # decode bytes 
    if isinstance(data, bytes):
        data = data.decode()
    print(f"{tag:25}: {data}")