我正在使用PIL。如何将EXIF数据转换为字典?在Python中,如何读取图像的exif数据?
68
A
回答
108
试试这个:
import PIL.Image
img = PIL.Image.open('img.jpg')
exif_data = img._getexif()
这应该给你通过EXIF数字标签索引的字典。如果您想通过实际的EXIF标签名称字符串索引的字典中,你可以试试:
import PIL.ExifTags
exif = {
PIL.ExifTags.TAGS[k]: v
for k, v in img._getexif().items()
if k in PIL.ExifTags.TAGS
}
+5
任何Python 3的替代? – 2013-08-30 04:57:31
20
您也可以使用ExifRead模块:
import exifread
# Open image file for reading (binary mode)
f = open(path_name, 'rb')
# Return Exif tags
tags = exifread.process_file(f)
11
我用这个:
import os,sys
from PIL import Image
from PIL.ExifTags import TAGS
for (k,v) in Image.open(sys.argv[1])._getexif().iteritems():
print '%s = %s' % (TAGS.get(k), v)
或获取特定字段:
def get_field (exif,field) :
for (k,v) in exif.iteritems():
if TAGS.get(k) == field:
return v
exif = image._getexif()
print get_field(exif,'ExposureTime')
相关问题
- 1. 阅读黑莓图像的EXIF数据
- 2. 读取的Exif数据8.1
- 3. 如何从回形针附加的图像中读取exif数据?
- 4. 阅读在Qt中图像的exif元数据
- 5. 如何在使用DKImagePickerController时使用exif数据获取图像?
- 6. 使用Ruby从远程图像高效读取EXIF元数据
- 7. 如何修改python中的EXIF数据
- 8. Codeigniter strip图像EXIF数据
- 9. Exif数据读写
- 10. 如何使用OpenCV获取图像Exif数据?
- 11. 图片exif /元数据阅读/写作?
- 12. 从Cocoa的图像中读取EXIF/IPTC信息
- 13. 如何读取Python中的cx_Oracle.LOB数据?
- 14. 如何从安卓相机图像中删除EXIF数据
- 15. 如何从CarrierWave图像中删除EXIF(相机)数据?
- 16. nodejs读取图像数据
- 17. 在新Activity中将EXIF数据读取到textView中
- 18. 从PDF中的图像读取数据
- 19. Python - 如何从URL读取图像?
- 20. 如何用C++或python从图像中读取图像描述?
- 21. 从android的字节数组中读取EXIF数据
- 22. 如何使用Coldfusion修改JPEG图像的EXIF元数据?
- 23. 如何使用PerlMagick提取EXIF数据?
- 24. 从图像中提取EXIF信息
- 25. python PIL调整图像维护EXIF元数据
- 26. 如何从CIF中读取EXIF中的镜头和创建者工具数据?
- 27. 如何在.NET中编辑EXIF数据
- 28. 从数据库中读取FOP图像
- 29. 从流数据库中读取图像
- 30. 获取相机胶卷图像及其EXIF数据?
更近期的问题在这里:http://stackoverflow.com/questions/14009148/exif-reading-library – 2013-04-24 12:58:59
请参阅这里的答案:http://stackoverflow.com/questions/765396/exif-manipulation-library-for-python – 2011-01-22 00:05:19
http://tilloy.net/dev/pyexiv2/tutorial.html这是最简单和最全面的。 – 2012-11-17 19:10:49