colour.read_image#

colour.read_image(path: str | Path, bit_depth: Literal['uint8', 'uint16', 'float16', 'float32', 'float64', 'float128'] = 'float32', method: Literal['Imageio', 'OpenImageIO'] | str = 'OpenImageIO', **kwargs: Any) NDArrayReal[source]#

Read the image data at given path using given method.

Parameters:
  • path (str | Path) – Image path.

  • bit_depth (Literal['uint8', 'uint16', 'float16', 'float32', 'float64', 'float128']) – Returned image bit-depth, for the Imageio method, the image data is converted with colour.io.convert_bit_depth() definition after reading the image, for the OpenImageIO method, the bit-depth conversion behaviour is driven directly by the library, this definition only converts to the relevant data type after reading.

  • method (Literal['Imageio', 'OpenImageIO'] | str) – Read method, i.e. the image library used for reading images.

  • additional_data – {colour.io.read_image_OpenImageIO()}, Whether to return additional data.

  • kwargs (Any)

Returns:

Image data.

Return type:

class`numpy.ndarray`

Notes

  • If the given method is OpenImageIO but the library is not available writing will be performed by Imageio.

  • If the given method is Imageio, kwargs is passed directly to the wrapped definition.

  • For convenience, single channel images are squeezed to 2D arrays.

Examples

>>> import os
>>> import colour
>>> path = os.path.join(
...     colour.__path__[0],
...     "io",
...     "tests",
...     "resources",
...     "CMS_Test_Pattern.exr",
... )
>>> image = read_image(path)
>>> image.shape  
(1267, 1274, 3)
>>> image.dtype
dtype('float32')