ImageMode¶
-
class
toasty.image.
ImageMode
(value)[source]¶ Bases:
enum.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
Methods Summary
Get the file extension to be used in this mode’s “default” save format.
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
-
F32
= 'F'¶
-
RGB
= 'RGB'¶
-
RGBA
= 'RGBA'¶
Methods Documentation
-
get_default_save_extension
()[source]¶ Get the file extension to be used in this mode’s “default” save format.
- Returns
- The extension, without a period; either “png” or “npy”
-
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.
-