letmaik / rawpy

📷 RAW image processing for Python, a wrapper for libraw
https://pypi.python.org/pypi/rawpy
MIT License
591 stars 67 forks source link

Unsufficient memory #47

Closed baidut closed 6 years ago

baidut commented 6 years ago

I tried

pip install rawpy
pip install imageio
python ./rawpy_demo.py

rawpy_demo.py

import rawpy
import imageio

path = '5.DNG'
with rawpy.imread(path) as raw:
    rgb = raw.postprocess()
imageio.imsave('5.tiff', rgb)

and Unsufficient memory (libraw error) reported.

Traceback (most recent call last):
  File "./rawpy_demo.py", line 6, in <module>
    rgb = raw.postprocess()
  File "rawpy/_rawpy.pyx", line 616, in rawpy._rawpy.RawPy.postprocess
  File "rawpy/_rawpy.pyx", line 583, in rawpy._rawpy.RawPy.dcraw_process
  File "rawpy/_rawpy.pyx", line 660, in rawpy._rawpy.RawPy.handle_error
rawpy._rawpy.LibRawFatalError: Unsufficient memory

rawpy-0.11.0 ubuntu 14.04 Python 2.7.12 |Anaconda 4.2.0 (64-bit)

Could you please kindly help me fix this error? Or should I report the issue at the LibRaw repo instead?

letmaik commented 6 years ago

Are you sure you have enough memory? The error message seems pretty self-explanatory, but yes, it's coming directly from LibRaw and you should ask directly over there.

baidut commented 6 years ago

Thank you for your kindly reply. Problem solved. LibRaw 0.19-Release might output this error. LibRaw 0.18.13 works fine.

letmaik commented 6 years ago

Interesting, is this a bug then in LibRaw? Is it reported?

takanokage commented 6 years ago

I've just encountered the same issue as well.

In my case, same code:

letmaik commented 6 years ago

@takanokage Does that mean you're building rawpy from source? If not, then you would use the Python binary wheel of rawpy which has libraw 0.19 bundled.

takanokage commented 6 years ago

hmm, I didn't know it was bundled. I was just trying to figure out why one machine works and one doesn't (same pip install rawpy on both, same code).

takanokage commented 6 years ago

any chance your install depends on files you assumed should be on the system? is there a way to check what are all the dependencies of rawpy?

I really need rawpy to work on the machine where it doesn't.

letmaik commented 6 years ago

You can figure out the version of libraw with print(rawpy.libraw_version). Can you share a minimal example code and possibly a test image that triggers this?

takanokage commented 6 years ago

rawpy.zip

This passes on one machine and fails on two other. Nothing special about the code, I imagine I have inadvertently messed up those machines myself.

In the meantime I have worked around the issue in another way so it's not so hot anymore.

takanokage commented 6 years ago

I have inspected the libraw version on the two machines:

oneTaken commented 6 years ago

I'm also has this problem. Ans I use pip install rawpy, and the libraw version with rawpy.libraw_versionis(0,19,0)

oneTaken commented 6 years ago

Everything is ok when I change the libraw version from 0.19.0 to 0.17.0.

letmaik commented 6 years ago

Please provide an example image and example code that reproduces this issue.

ndeebook commented 6 years ago

I experience the same problem.

Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2 libraw 0.19.0, rawpy 0.11.0

http://www.mannyphoto.com/D700D3/DSC_0658.NEF

import rawpy
path = 'DSC_0658.NEF'
with rawpy.imread(path) as raw:
    rgb = raw.postprocess()

Traceback (most recent call last): File "", line 2, in File "rawpy/_rawpy.pyx", line 616, in rawpy._rawpy.RawPy.postprocess File "rawpy/_rawpy.pyx", line 583, in rawpy._rawpy.RawPy.dcraw_process File "rawpy/_rawpy.pyx", line 660, in rawpy._rawpy.RawPy.handle_error rawpy._rawpy.LibRawFatalError: Unsufficient memory

letmaik commented 6 years ago

Thanks everyone for reporting. I could reproduce the issue on Python 3. It seems it only happens on Linux, while Windows is fine. Anyone had the issue on a Mac? EDIT: Just tested on a Mac and couldn't reproduce.

letmaik commented 6 years ago

https://github.com/cchen156/Learning-to-See-in-the-Dark/issues/34 also noticed the error, but no mention of the OS, I assume Linux though.

In https://github.com/LibRaw/LibRaw/issues/171 it looks like it is a bug in libraw fixed in latest master. I'll try that out and report back.

letmaik commented 6 years ago

OK, indeed a bug in libraw, works with the latest patches. I'll release a new version of rawpy asap.

letmaik commented 6 years ago

A new version is out now which includes a fix for this issue.