当试图设置一个程序来自动检查所有文件并将其从.cr2转换为.tif时,我遇到了两个主要错误,不支持的Libraw版本和KeyError:19。
我试图安装libraw的较新版本。
def convert_to_tiff(picture):
for i in range(len(picture)):
filename = 'DSC_Canon EOS 1300D (' + str(picture[i]) + ').cr2'
raw_image = Raw(filename)
buffered_image = np.array(raw_image.to_buffer())
image = Image.frombytes('RGB', (raw_image.metadata.width, raw_image.metadata.height), buffered_image)
folder_name = input("Enter folder name: ")
image.save("" + folder_name + "/" + str(picture[i]) + ".tif", format="tiff")
。
Traceback (most recent call last):
File "/home/anish/Python/CAMERA/venv/lib/python3.7/site-packages/libraw/bindings.py", line 46, in __init__
}[self.version_number[1]]
KeyError: 19
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/anish/Python/CAMERA/automation.py", line 35, in <module>
convert_to_tiff(picture)
File "/home/anish/Python/CAMERA/automation.py", line 25, in convert_to_tiff
raw_image = Raw(filename)
File "/home/anish/Python/CAMERA/venv/lib/python3.7/site-packages/rawkit/raw.py", line 70, in __init__
self.libraw = LibRaw()
File "/home/anish/Python/CAMERA/venv/lib/python3.7/site-packages/libraw/bindings.py", line 49, in __init__
'Unsupported Libraw version: %s.%s.%s.' % self.version_number
ImportError: Unsupported Libraw version: 0.19.2.
Process finished with exit code 1
我希望程序将图像从cr2转换为tiff,但会出错处理。