from_png#
- static rlemasklib.RLEMask.from_png(path=None, data=None, threshold=1)[source]#
Create an RLEMask from an 8-bit grayscale PNG.
This is a fast path that avoids materializing the full pixel array, converting directly from PNG to RLE representation.
- Parameters:
- Returns:
An RLEMask object representing the mask.
- Raises:
ValueError – If neither path nor data is provided, or both are provided, or if the PNG is not 8-bit grayscale.
- Return type:
Note
Only 8-bit grayscale PNGs are supported. For other formats, use PIL/Pillow/OpenCV to load the image and convert with RLEMask.from_array().