ImageMode¶
- class toasty.image.ImageMode(value)[source]¶
Bases:
Enum
Allowed image “modes”, describing their pixel data formats.
These align with PIL modes when possible, but we expect to need to support modes that aren’t present in PIL (namely, float64). There are also various obscure PIL modes that we do not support.
Attributes Summary
48-bit color with three 16-bit floating-point channels for red, green, and blue.
32-bit floating-point scalar data.
64-bit floating-point scalar data.
16-bit integer data.
32-bit integer data.
24-bit color with three uint8 channels for red, green, and blue.
32-bit color with four uint8 channels for red, green, blue, and alpha (transparency).
Methods Summary
from_array_info
(shape, dtype)make_maskable_buffer
(buf_height, buf_width)Return a new, uninitialized buffer of the specified shape, with a mode compatible with this one but able to accept undefined values.
Attempt to convert this mode into a PIL image mode string.
Attributes Documentation
- F16x3 = 'F16x3'¶
48-bit color with three 16-bit floating-point channels for red, green, and blue.
This mode is useful for high-dynamic-range image processing and can be stored in the OpenEXR file format.
- F32 = 'F'¶
32-bit floating-point scalar data.
- F64 = 'D'¶
64-bit floating-point scalar data.
- I16 = 'I16'¶
16-bit integer data.
- I32 = 'I32'¶
32-bit integer data.
- RGB = 'RGB'¶
24-bit color with three uint8 channels for red, green, and blue.
- RGBA = 'RGBA'¶
32-bit color with four uint8 channels for red, green, blue, and alpha (transparency).
- U8 = 'U8'¶
Methods Documentation
- make_maskable_buffer(buf_height, buf_width)[source]¶
Return a new, uninitialized buffer of the specified shape, with a mode compatible with this one but able to accept undefined values.
- Parameters:
- buf_heightint
The height of the new buffer
- buf_widthint
The width of the new buffer
- Returns:
- An uninitialized
Image
instance.
- An uninitialized
Notes
“Maskable” means that the buffer can accommodate undefined values. If the image is RGB or RGBA, that means that the buffer will have an alpha channel. If the image is scientific, that means that the buffer will be able to accept NaNs.