Write Functions¶
Each of these functions takes a ColorCorrection as an arg, then places as many attributes of the ColorCorrection that the format supports into a properly formatted string or XML Tree, then writes that file.
write_cc¶
Write XML Color Correction (cc) files.
- cdl_convert.write.write_cc(cdl: ColorCorrection) None[source]¶
Write a ColorCorrection to a .cc XML file.
- Parameters:
cdl (ColorCorrection) – The ColorCorrection instance to write. Must have a valid file_out attribute set to the target file path.
- Raises:
CDLConvertError – If the file cannot be written, with the original OSError chained for context. This includes permission errors, disk space issues, or invalid file paths.
Example
>>> from pathlib import Path >>> cc = ColorCorrection("test_id") >>> cc.file_out = Path("output.cc") >>> cc.slope = [1.2, 1.1, 1.0] >>> write_cc(cc) # Writes XML to output.cc
write_ccc¶
Write XML Color Correction Collection (ccc) files.
- cdl_convert.write.write_ccc(cdl: ColorCorrection | ColorCollection) None[source]¶
Write a ColorCollection to a .ccc XML file.
Accepts either a single ColorCorrection (which gets wrapped in a temporary collection) or a full ColorCollection.
- Parameters:
cdl (Union[ColorCorrection, ColorCollection]) – The color correction data to write. If a ColorCorrection is provided, it will be wrapped in a temporary ColorCollection.
- Raises:
CDLConvertError – If the file cannot be written, with the original OSError chained for context. This includes permission errors, disk space issues, or invalid file paths.
Example
>>> from pathlib import Path >>> # Write a single correction >>> cc = ColorCorrection("test_id") >>> cc.file_out = Path("output.ccc") >>> write_ccc(cc)
>>> # Write a collection >>> collection = ColorCollection() >>> collection.append_child(cc) >>> collection.file_out = Path("collection.ccc") >>> write_ccc(collection)
write_cdl¶
Write XML Color Decision List (cdl) files.
- cdl_convert.write.write_cdl(cdl: ColorCorrection | ColorCollection) None[source]¶
Write a ColorCollection to a .cdl XML file.
Accepts either a single ColorCorrection (which gets wrapped in a temporary collection) or a full ColorCollection.
- Parameters:
cdl (Union[ColorCorrection, ColorCollection]) – The color correction data to write. If a ColorCorrection is provided, it will be wrapped in a temporary ColorCollection.
- Raises:
CDLConvertError – If the file cannot be written, with the original OSError chained for context. This includes permission errors, disk space issues, or invalid file paths.
Example
>>> from pathlib import Path >>> # Write a single correction as CDL >>> cc = ColorCorrection("test_id") >>> cc.file_out = Path("output.cdl") >>> write_cdl(cc)
>>> # Write a collection as CDL >>> collection = ColorCollection() >>> collection.append_child(cc) >>> collection.file_out = Path("collection.cdl") >>> write_cdl(collection)
write_nk¶
Write Foundry Nuke OCIOCDLTransform node files.
This writes a Nuke script file containing an OCIOCDLTransform node with the CDL color correction values. The generated file can be directly loaded into Nuke and will apply the specified color correction.
- cdl_convert.write.write_nk(cdl: ColorCorrection) None[source]¶
Write ColorCorrection to Nuke OCIOCDLTransform format.
Generates a Nuke script file containing an OCIOCDLTransform node with the CDL color correction values. The output format uses Nuke’s standard node syntax with curly braces for structure.
The generated OCIOCDLTransform node can be directly loaded into Nuke and will apply the specified color correction values.
- Parameters:
cdl (ColorCorrection) – The ColorCorrection instance to write. Must have a valid file_out attribute set to the target file path.
- Raises:
CDLConvertError – If file_out is not set or if the file cannot be written, with the original OSError chained for context.
Example
>>> from pathlib import Path >>> cc = ColorCorrection("shot_001") >>> cc.file_out = Path("output.nk") >>> cc.slope = [1.2, 1.1, 1.0] >>> cc.sat = 0.9 >>> write_nk(cc) # Writes Nuke node to output.nk
write_rnh_cdl¶
Write Rhythm & Hues CDL format.
This writes a very sparse cdl format that is based on a very early spec of the cdl implementation. It lacks all metadata. Unless you work at Rhythm & Hues, a VFX company which hasn’t existed for years now, you probably don’t want to write a cdl that uses this format.
- cdl_convert.write.write_rnh_cdl(cdl: ColorCorrection) None[source]¶
Writes the ColorCorrection to a space separated .cdl file