在Python中,如何读取图像的exif数据? [英] In Python, how do I read the exif data for an image?
本文介绍了在Python中,如何读取图像的exif数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PIL。如何将EXIF数据转换为字典?
I'm using PIL. How do I turn the EXIF data into a dictionary of stuff?
推荐答案
试试这个:
import PIL.Image
img = PIL.Image.open('img.jpg')
exif_data = img._getexif()
这应该会给你一个由EXIF数字标签索引的字典。如果您想要按实际EXIF标记名称字符串索引的字典,请尝试以下操作:
This should give you a dictionary indexed by EXIF numeric tags. If you want the dictionary indexed by the actual EXIF tag name strings, try something like:
import PIL.ExifTags
exif = {
PIL.ExifTags.TAGS[k]: v
for k, v in img._getexif().items()
if k in PIL.ExifTags.TAGS
}
这篇关于在Python中,如何读取图像的exif数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文