colour.write_image#

colour.write_image(image: ArrayLike, path: str, bit_depth: Literal['uint8', 'uint16', 'float16', 'float32', 'float64', 'float128'] = 'float32', method: Union[Literal['Imageio', 'OpenImageIO'], str] = 'OpenImageIO', **kwargs: Any) bool[source]#

Write given image data at given path using given method.

Parameters:
Returns:

Definition success.

Return type:

bool

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.

  • It is possible to control how the image are saved by the Freeimage backend by using the flags keyword argument and passing a desired value. See the Load / Save flag constants section in https://sourceforge.net/p/freeimage/svn/HEAD/tree/FreeImage/trunk/Source/FreeImage.h

Examples

Basic image writing:

>>> import os
>>> import colour
>>> path = os.path.join(colour.__path__[0], 'io', 'tests', 'resources',
...                     'CMS_Test_Pattern.exr')
>>> image = read_image(path)  
>>> path = os.path.join(colour.__path__[0], 'io', 'tests', 'resources',
...                     'CMSTestPattern.tif')
>>> write_image(image, path)  
True

Advanced image writing while setting attributes using OpenImageIO:

>>> compression = ImageAttribute_Specification('Compression', 'none')
>>> write_image(image, path, bit_depth='uint8', attributes=[compression])
... 
True