我正在尝试使用以下代码从图像中提取标头数据中的 xml blob(在黑暗中真正刺伤):
import exifread
Open image file for reading (binary mode)
open('img.jpg', 'rb')
tags = exifread.process_file(f)
for tag in tags.keys():
if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
print ("Key: %s, value %s") % (tag, tags[tag])
print(tags)
但是我收到以下消息:
==== RESTART: C:/Users/richie/Desktop/work/exif_read4.py ============
{}
>>>
我知道该文件在标题中包含数据,但它可能不是 exif 格式。以下是 Imagej 中显示的信息示例:
[JpegComment] Jpeg Comment: <?xml version="1.0" encoding="utf-8"?>
<image time="15:27:56.763207" date="2016.02.03" acq_index="3692">
<acquisition>
<exposure>10000</exposure>
<sensor_digital_gain>4</sensor_digital_gain>
<aperture>4</aperture>
<focus>68</focus>
<digital_gain>1</digital_gain>
<name>Photo_pose</name>
<camera_session_name>EXI-55-retest-3</camera_session_name>
</acquisition>
<errors>
谁能想到提取这些数据的方法?