colour.io.image Module

Image Input / Output Utilities

Defines image related input / output utilities objects.

class colour.io.image.BitDepth_Specification(name, numpy, openimageio, domain, clip)

Bases: tuple

Create new instance of BitDepth_Specification(name, numpy, openimageio, domain, clip)

clip

Alias for field number 4

domain

Alias for field number 3

name

Alias for field number 0

numpy

Alias for field number 1

openimageio

Alias for field number 2

colour.io.image.read_image(path, bit_depth=u'float32')[source]

Reads given image using OpenImageIO.

Parameters:
  • path (unicode) – Image path.
  • bit_depth (unicode, optional) – {‘float32’, ‘uint8’, ‘uint16’, ‘float16’}, Image bit_depth.
Returns:

Image as a ndarray.

Return type:

ndarray

Notes

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

Examples

>>> import os
>>> path = os.path.join('tests', 'resources', 'CMSTestPattern.exr')
>>> image = read_image(path)  
colour.io.image.write_image(image, path, bit_depth=u'float32')[source]

Writes given image using OpenImageIO.

Parameters:
  • image (array_like) – Image data.
  • path (unicode) – Image path.
  • bit_depth (unicode, optional) – {‘float32’, ‘uint8’, ‘uint16’, ‘float16’}, Image bit_depth.
Returns:

Definition success.

Return type:

bool

Examples

>>> import os
>>> path = os.path.join('tests', 'resources', 'CMSTestPattern.exr')
>>> image = read_image(path)  
>>> path = os.path.join('tests', 'resources', 'CMSTestPattern.png')
>>> write_image(image, path, 'uint8')  
True