letmaik / rawpy

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

catching corruptions #228

Open eroux opened 3 months ago

eroux commented 3 months ago

I'm processing a lot of files where a few of them have some corruption and I want to be able to catch that, unfortunately in most cases no exception is raised, the only thing that happens is that a warning is printed. For instance the following code:

import rawpy
import imageio

with rawpy.imread("M0054341_01_00005.cr2") as raw:
    rgb = raw.postprocess(output_bps=8, use_camera_wb=True, user_flip=0)
imageio.imsave('test.jpg', rgb)

on the following file:

M0054341_01_00005.zip

results in the following warning printed:

M0054341_01_00005.cr2: data corrupted at 3764709

and the following result:

raw_converted

Would it be possible to raise an exception in that case instead of printing a warning?

eroux commented 3 months ago

I guess https://github.com/letmaik/rawpy/pull/76 is a good solution

eroux commented 3 months ago

WIP PR in #229