madam.raw module
Raw camera image processor using rawpy (LibRaw).
The optional raw dependency group must be installed:
uv sync --extra raw
- class madam.raw.RawImageProcessor(config: Mapping[str, Any] | None = None)[source]
Bases:
ProcessorRepresents a processor that handles raw camera image formats (DNG, CR2, NEF, ARW, and any other format supported by LibRaw).
Reading and decoding require the rawpy package, which is a Python binding for LibRaw. Pillow is used to encode the decoded image into the requested output format.
Install the optional
rawextra to get both dependencies:pip install madam[raw]
- __init__(config: Mapping[str, Any] | None = None) None[source]
Initializes a new
RawImageProcessor.- Parameters:
config – Mapping with settings.
- can_read(file: IO) bool[source]
Returns whether the specified MIME type is supported by this processor.
- Parameters:
file (IO) – file-like object to be tested
- Returns:
whether the data format of the specified file is supported or not
- Return type:
- decode(asset: Asset, mime_type: str = 'image/png') Asset[source]
Demosaics a raw camera image and returns the result as a standard raster image asset.
Demosaicing is performed with LibRaw using automatic white balance. The result is encoded into the format specified by mime_type.
- Parameters:
- Returns:
Decoded raster image asset
- Return type:
- Raises:
OperatorError – if mime_type is not supported
- read(file: IO) Asset[source]
Reads a raw camera image file and returns an
Asset.The essence contains the original raw bytes unchanged. The
widthandheightmetadata attributes reflect the full sensor dimensions before demosaicing.- Parameters:
file (IO) – Readable binary file-like object containing raw image data
- Returns:
Asset with
mime_type='image/x-raw',width, andheight- Return type: