更新时间:2023-01-24 14:15:47
使用Pillow
,它是仍在积极开发中的PIL的分支,并且支持python3.在这里,我使用字典生成器将exif数据映射到字典
Use Pillow
, it's a fork of PIL that is still in active development, and supports python3. Here I use a dict generator to map the exif data to a dict
from PIL import Image, ExifTags
img = Image.open("/path/to/file.jpg")
exif = { ExifTags.TAGS[k]: v for k, v in img._getexif().items() if k in ExifTags.TAGS }