Skip to content

Commit

Permalink
updated rawpy plugin read method
Browse files Browse the repository at this point in the history
  • Loading branch information
tahseenadit committed Feb 21, 2024
1 parent ac77a7c commit 7efd04c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions imageio/plugins/rawpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, request: Request) -> None:
self._image: rawpy = None
self._image_file = request.get_file()

def read(self, *, index: int = 0) -> np.ndarray:
def read(self, *, index: int = 0, **kwargs) -> np.ndarray:
"""Read Raw Image.
Returns
Expand All @@ -49,11 +49,14 @@ def read(self, *, index: int = 0) -> np.ndarray:
The image data
"""

nd_image = None

if self._request.mode.io_mode == IOMode.read:
try:
with rawpy.imread(self._image_file) as raw_image:
self._image = raw_image.raw_image
except (AttributeError, TypeError, rawpy.LibRawIOError) as ex:
self._image = raw_image.postprocess(**kwargs)
nd_image = self._image
except (AttributeError, TypeError) as ex:
print(ex)
except (rawpy.NotSupportedError, rawpy.LibRawError, rawpy.LibRawFatalError, rawpy.LibRawNonFatalError) as ex:
print(ex)
Expand All @@ -62,5 +65,6 @@ def read(self, *, index: int = 0) -> np.ndarray:
else:
print("Read is not supported!")

return np.asarray(self._image)
return nd_image


0 comments on commit 7efd04c

Please sign in to comment.