python读取tif图片_在Python中读取TIFF图像元数据

本文介绍了如何在Python中使用PIL库解析TIFF图像文件的元数据,尽管_exif()方法不适用于TIFF,但展示了如何通过PIL的TiffTags模块间接获取元数据。着重于PIL处理TIFF文件的复杂性和不同寻常的方法。
摘要由CSDN通过智能技术生成

1586010002-jmsa.png

How can I read metada, like coordinates, from a TIFF image in Python? I tried foo._getexif() from PIL, but got the message:

AttributeError: 'TiffImageFile' object has no attribute '_getexif'

Is it possible to get it with 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() is only meant to be used with JPEG. JPEG requires unpacking of the metadata, TIFF does not. That said, PIL does not naively read Exif tags or directory (less straightforward) TIFF metadata.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值