Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Converting ORF to jpg - LibRawFatalError: Input/output error

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?

like image 594
RyeGuy Avatar asked Sep 24 '26 17:09

RyeGuy


1 Answers

This code works for me.

Please note that the path should be relative to the .py file you have.

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)
like image 90
mzage Avatar answered Sep 27 '26 09:09

mzage



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!