Using color management

The SDColorManagementEngine class, accessible from the SDApplication class, contains information about the current color management settings.

Accessing and querying the Color Management Engine
import sd

ctx = sd.getContext()
app = ctx.getSDApplication()

# Access the color management engine.
cm = app.getColorManagementEngine()

# Currently getName can return "legacy", "ace" or "ocio"
# depending on the color management settings in the preferences.
cmName = cm.getName() 


if cmName == "ocio":
    # If OpenColorIO is enabled, print the config file name.

# List all color spaces.
colorSpaces = cm.getColorSpaces()
for cs in colorSpaces:

In addition, it is possible to assign color spaces to bitmap resources from Python.

Setting color spaces on bitmap resources
import sd
import sd
from sd.api.sdproperty import *
from sd.api.sdresourcebitmap import SDResourceBitmap
from sd.api.sdvaluestring import SDValueString
from sd.api.sdvaluebool import SDValueBool

ctx = sd.getContext()
app = ctx.getSDApplication()
pkgMgr = app.getPackageMgr()
cm = app.getColorManagementEngine()

colorSpaces = cm.getColorSpaces()

# Get all the resources in the first package.
pkg = pkgMgr.getPackages()[0]
resources = pkg.getChildrenResources(isRecursive=True)

for res in resources:
	if isinstance(res, SDResourceBitmap):
		props = res.getProperties(SDPropertyCategory.Annotation)

        # Print the current color space for the resource.
		p0 = res.getPropertyFromId("bitmap_color_space", SDPropertyCategory.Annotation)
		cs = res.getAnnotationPropertyValueFromId("bitmap_color_space")

        # Print the current premultiplied alpha setting for the resource.
		p1 = res.getPropertyFromId("bitmap_premultiplied_alpha", SDPropertyCategory.Annotation)
		cs = res.getAnnotationPropertyValueFromId("bitmap_premultiplied_alpha")

        # Assign new values for the color space and premultiplied alpha properties.
		res.setPropertyValue(p0, colorSpaces[2])
		res.setPropertyValue(p1, SDValueBool.sNew(False))

Writing SDTextures with color space conversions

The save method of the SDTexture class now accepts an optional outputColorSpace parameter. When specified, the color space conversion will be applied before saving the image.

If the color management mode supports embedded ICC profiles and the destination file format also supports them, the color space ICC profile will be embedded in the resulting image file.