3

I am trying to convert a directory of photos from ORF to jpg using python. The image library I am using is

https://github.com/letmaik/rawpy

An error is occuring when I try to read an image from the path. The error is below

  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)

There is most definitely an ORF image at the fullpath variable.

What am I doing wrong?

4

1 回答 1

2

这段代码对我有用。

请注意,路径应该相对于您拥有的 .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)
于 2018-10-31T03:57:12.023 回答