如何使用python从图像中提取元数据? [英] How to extract metadata from a image using python?

查看:480
本文介绍了如何使用python从图像中提取元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发一个程序,该程序将打开图像,然后从图像中提取元数据 如何使用python提取元数据?

Hi im working on a program that will open an image and then extract the metadata from it How do i extract metadata using python ?

谢谢

推荐答案

使用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 }

这篇关于如何使用python从图像中提取元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆