我一直使用pyexiv2从python的JPEG文件中读取exif信息,并注意到exiv2报告的一个特别的标签- libexif -与另一个exif库libexif不同。
我尝试过的任何基于exiv2的实用程序都会将exposuretime标记简化为一个“有理”值,比如0/1、0或类似的值。基于libexif的实用程序(特别是工具"exif")将报告更详细的"1/-21474836秒“。对于相同的标签,在相同的图像中。
首先,我想了解一下:这种差异可以用什么来解释?我假设两者中的后一个是正确的。
其次,假设libexif报告的更详细的标记是正确的,我希望能够在Python语言中获得这个值,在我看来,使用我遇到的任何EXIF工具(例如pyexiv2)都是不可能的。有没有我没有考虑的工具或方法?
我偶然发现了一个潜在的解决方案,在python中使用libexif C库,并将ctype用作noted in this previously answered question -尽管我找不到如何做到这一点的示例。
任何帮助都是非常感谢的。谢谢!
发布于 2017-08-27 04:12:36
如果这有帮助,这里有一些我最近做的设置丢失镜头/ F-Number的技巧,..当我使用手动镜头时,我计算了actaul绝对EV,以供后来的HDR处理工具(HDR亮度)自动检索。为了安全起见,我在下面注释掉了"write“操作。应该是不言而喻的。
顶部文件部分列出了当前文件夹中要处理的文件(此处为所有*.ARW (索尼raw文件))。根据需要调整图案和路径。
#!/usr/bin/env python
import os
import time
import array
import math
# make file list (take all *.ARW files in current folder)
files = [f for f in os.listdir(".") if f.endswith(".ARW")]
files.sort() # just to be nice
# have a dict. of tags to work with in particular
tags = {'Aperture':10., 'Exposure Time ':1./1250, 'Shutter Speed':1./1250, 'ISO':200., 'Stops Above Base ISO':0., 'Exposure Compensation':0. }
# arbitrary chosen base EV to get final EV compensation numbers into +/-10 range
EVref = math.log (math.pow(tags['Aperture'],2.0)/tags['Shutter Speed'], 2.0) - 4
print ('EVref=', EVref)
for f in files:
print (f)
meta=os.popen("exiftool "+f).readlines()
for tag in meta:
set = str(tag).rstrip("\n").split(":")
for t,x in tags.items():
if str(set[0]).strip(" ") == t:
tags[t] = float ( str(os.popen("calc -- "+set[1]).readlines()).strip("[]'~\\t\\n"))
print (t, tags[t], set[1])
ev = math.log (math.pow(tags['Aperture'],2.0)/tags['Shutter Speed'], 2.0)
EV = EVref - ev + tags['Stops Above Base ISO']
print ('EV=', EV)
# uncomment/edit to update EXIF in place:
# os.system('exiftool -ExposureCompensation='+str(EV)+' '+f)
# os.system('exiftool -FNumber=10 '+f)
# os.system('exiftool -FocalLength=1000.0 '+f)
# os.system('exiftool -FocalLengthIn35mmFormat=1000.0 '+f)https://stackoverflow.com/questions/23000071
复制相似问题