我需要按拍摄日期提取和组织照片。 Windows 10、Python 2.7。我一直在这样做
from PIL import Image
def get_date_taken(path):
return Image.open(path)._getexif()[36867]
下列的:
使用 PIL 从 EXIF 数据获取照片拍摄的日期和时间 https://stackoverflow.com/questions/23064549/get-date-and-time-when-photo-was-taken-from-exif-data-using-pil
这对于某些照片来说非常有用。
伟大的。现在抓取一组不同的图像,新相机,属性看起来相似。
但字典完全不同
Image.open(image)._getexif()[36867]
Traceback (most recent call last):
Debug Probe, prompt 369, line 1
KeyError: 36867
Image.open(image)._getexif()
{36864: '0220', 37121: '\x01\x02\x03\x00', 40962: 2048, 40963: 1536, 40960: '0100', 40961: 1, 296: 2, 34665: 90, 34855: 1600, 531: 2, 282: (72, 1), 283: (72, 1), 37500: '\x01\xf1\x03\x00\x03\x00\x00\x00\x11 ....
我也尝试过exifread
a=exifread.process_file(open(image,'rb'))
a.keys()
['EXIF MakerNote', 'Image ExifOffset', 'EXIF ExposureTime', 'EXIF ComponentsConfiguration', 'Image YCbCrPositioning', 'Image XResolution', 'EXIF FlashPixVersion', 'EXIF ISOSpeedRatings', 'Image YResolution', 'EXIF ColorSpace', 'EXIF ExifImageLength', 'EXIF ExifVersion', 'Image ResolutionUnit', 'EXIF ExifImageWidth']
但没有拍摄日期。 windows 读什么而 python 不读?关于还有什么可以尝试的建议,我需要担心跨平台吗?与这里相同的问题:
“拍摄日期”未显示在图像 PropertyItems 中,而显示在 Windows 资源管理器的文件详细信息(文件属性)中 https://stackoverflow.com/questions/14308284/date-taken-not-showing-up-in-image-propertyitems-while-it-shows-in-file-detail
但在Python中。这个友好的在线元数据查看器
http://exif.regex.info/exif.cgi http://exif.regex.info/exif.cgi
表明这两个图像在 exif 中都有创建日期标签。还有什么方法可以访问它们?
有问题的图像示例是here https://www.dropbox.com/s/8fue8vufgebihuy/p1d107s100i10.JPG?dl=0