Skip to main content
 首页 » 编程设计

Python 将 ORF 转换为 jpg之LibRawFatalError : Input/output error

2024年12月31日8lidabo

我正在尝试使用 python 将照片目录从 ORF 转换为 jpg。我使用的图片库是

https://github.com/letmaik/rawpy

当我尝试从路径中读取图像时发生错误。错误如下

  with rawpy.imread(fullPath) as raw: 
  File "/Library/Python/2.7/site-packages/rawpy/__init__.py", line 20, in imread 
    d.open_file(pathOrFile) 
  File "rawpy/_rawpy.pyx", line 266, in rawpy._rawpy.RawPy.open_file 
  File "rawpy/_rawpy.pyx", line 668, in rawpy._rawpy.RawPy.handle_error 
rawpy._rawpy.LibRawFatalError: Input/output error 

imageConversion.py

path = '/Users/Account/Desktop/ORFImages' 
for (dirpath, dirnames, filenames) in walk(path): 
    for l in filenames: 
         fullPath = str(join(dirpath,l)) 
         with rawpy.imread(fullPath) as raw: #ERROR OCCURS HERE 
             rgb = raw.postprocess() 
             imageio.imwrite('test.jpg', rgb) 

在全路径变量中肯定有一个 ORF 图像。

我做错了什么?

请您参考如下方法:

这段代码对我有用。

请注意路径应该是相对于您拥有的 .py 文件。

import glob 
import rawpy 
import imageio 
 
path = "ORFImages/*orf" 
for infile in glob.glob(path): 
    with rawpy.imread(infile) as raw: 
        rgb = raw.postprocess() 
        imageio.imwrite('test.jpg', rgb)