colour.write_image#
- colour.write_image(image: ArrayLike, path: str | PathLike, bit_depth: Literal['uint8', 'uint16', 'float16', 'float32', 'float64', 'float128'] = 'float32', method: Literal['Imageio', 'OpenImageIO'] | str = 'OpenImageIO', **kwargs: Any) bool[source]#
Write image data to the specified path.
- Parameters:
image (ArrayLike) – Image data to write.
bit_depth (Literal['uint8', 'uint16', 'float16', 'float32', 'float64', 'float128']) – Bit-depth to write the image at. For the Imageio method, the image data is converted with
colour.io.convert_bit_depth()definition prior to writing the image.method (Literal['Imageio', 'OpenImageIO'] | str) – Image writing backend library.
attributes – {
colour.io.write_image_OpenImageIO()}, An array ofcolour.io.Image_Specification_Attributeclass instances used to set attributes of the image.kwargs (Any)
- Returns:
Definition success.
- Return type:
Notes
If the specified method is OpenImageIO but the library is not available writing will be performed by Imageio.
If the specified method is Imageio,
kwargsis passed directly to the wrapped definition.It is possible to control how the images are saved by the Freeimage backend by using the
flagskeyword 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 = Image_Specification_Attribute("Compression", "none") >>> write_image(image, path, bit_depth="uint8", attributes=[compression]) ... True