pyflink.multimodal.operators.image_decode#
- image_decode(*columns, on_error='raise', mode=None, pixel_limit=None, concurrency=None)[source]#
Decode encoded image bytes into a decoded image.
This is the pipeline entry point for image data quality handling.
- Parameters
*columns – Optional image columns. When provided, the UDF is applied directly instead of returning a factory.
on_error – Handling strategy for corrupt or undecodable images: -
"raise"(default): raise an exception and stop processing. -"null": output null so downstream operators skip the row.mode – Optional target mode to convert to, e.g. “RGB” or “L16”.
Nonepreserves the decoded mode when it can be represented. Setmode="RGB"explicitly before model operators that require normalized RGB input.pixel_limit – Decompression bomb guard. A small compressed file can expand to billions of pixels and OOM the TaskManager. When set, image dimensions are read from the file header (zero-decode cost) and images with
width * height > pixel_limitare rejected before any pixel allocation. Follows theon_errorstrategy: raises on"raise", returns null on"null".None(default) falls back to PIL’s globalMAX_IMAGE_PIXELS(~178 million).concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF producing decoded image values.
- Example::
>>> # As a reusable variable >>> decode = image_decode(on_error="null") >>> df = df.with_columns("img", decode(col("raw_bytes"))) >>> >>> # Inline >>> df = df.with_columns("img", image_decode(col("raw_bytes"), on_error="null"))