我正在编写 python 脚本,我需要从原始照片文件(例如 .CR2)中获取 exif 信息。
我发现 Python Rawkit提供了这样做的能力。
with Raw(filename=image_path) as raw:
print raw.metadata
Metadata(aperture=-1.2095638073643314e+38, timestamp=4273602232L,
shutter=-1.1962713245823862e+38, flash=True,
focal_length=-1.2228562901462766e+38, height=3753,
iso=-1.182978841800441e+38,
make='Canon', model='EOS 5D Mark II',
orientation=0, width=5634)
Run Code Online (Sandbox Code Playgroud)
但我有点困惑,如何读取这些值?。例如,我期待像100/200/400这样的iso值,但什么是-1.182978841800441e+38?
我的问题不是针对iso的,也针对快门、光圈……
我检查了libraw和 rawkit doc,但无法找到如何读取/转换这种值。
文档中的这部分不是很详细:
float iso_speed;
ISO sensitivity.
float shutter;
Shutter speed.
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我理解如何阅读这些值吗?
谢谢
[更新]
正如neo所建议的,我将使用ExifRead。事实上,这是一个更好的选择,我正在编写一个 python 脚本。使用 ExifRead 不需要额外的 C 库依赖项。
我能够打开佳能原始文件并解析 Exif,但不幸的是遇到了错误的光圈值:
EXIF ApertureValue (Ratio): 3
# My photo was taken in 2.8 (maybe a rounded value on …Run Code Online (Sandbox Code Playgroud)