获取图片属性详细信息
获取图片属性详细信息,通过PIL库实现,PIL库为2.9.0(3.0版本以下)
python代码实现
#-*-coding:utf8-*- from PIL import Image from PIL.ExifTags import TAGS img = Image.open("img.jpg") print img.size, img.format, img.mode, img.bits print dir(img) print hasattr(img, '_getexif') exifdata = img._getexif() ret = {} for tag, value in exifdata.items(): decode = TAGS.get(tag, tag) ret[decode] = value print ret['DateTimeOriginal'] fp = open("text.txt","wb") fp.write(str(ret)) fp.close() print exifdata[0x9003]
http://blog.csdn.net/hnllei/article/details/6972858