如何从 Python 中的 TIFF 图像中读取元数据(如坐标)?我尝试了 PIL 的 foo._getexif()
,但收到了消息:
AttributeError: 'TiffImageFile' object has no attribute '_getexif'
是否可以通过 PIL 获取它?
最佳答案
from PIL import Image
from PIL.TiffTags import TAGS
with Image.open('image.tif') as img:
meta_dict = {TAGS[key] : img.tag[key] for key in img.tag.iterkeys()}
_getexif() 仅适用于 JPEG。 JPEG 需要解包元数据,而 TIFF 不需要。也就是说,PIL 不会天真地读取 Exif 标签或目录(不太直接)TIFF 元数据。
关于python - 在 Python 中读取 tiff 图像元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46477712/