Transforms¶
lcms2.convert(data, src, dst, **options) is the one-call form; lcms2.Transform is the reusable one.
Both take the same options.
Options¶
Option |
Meaning |
|---|---|
|
|
|
Black-point compensation. |
|
Soft proofing through a third profile: colors outside its gamut are clipped (RGB matrix profiles too), so the result previews what the proof device can show; |
|
|
|
|
|
Any |
|
Output dtype, or a preallocated output array. |
proof = lcms2.Transform("sRGB", "sRGB", proof=lcms2.Profile("press.icc"), gamut_check=True)
lcms2.set_alarm_codes([0xFFFF, 0, 0xFFFF]) # magenta instead of gray
preview = proof(img)
Chains¶
A list of profiles makes one multi-profile transform; per-profile intent, bpc and adaptation lists
build an extended transform.
t = lcms2.Transform(["sRGB", lcms2.Profile.abstract(contrast=1.2), "press.icc"])
Device links¶
link = t.to_device_link() # a Profile; save and use it in any CMS
Explicit formats¶
When you need a specific LittleCMS pixel layout (planar, swapped bytes, premultiplied alpha, …) pass format
names; see lcms2.FORMATS for all 178:
t = lcms2.Transform(srgb, "RGB_8", prophoto, "RGB_16")
Threads¶
The GIL is released while pixels are converted and transforms keep no per-call state, so one Transform can
be called from several threads at once.
Large inputs are also split for you: a transform, lcms2.delta_e or a colormap lookup over 262,144
pixels or more runs in parallel chunks on a shared pool of min(os.cpu_count(), 16) threads. The result
is identical to a single-threaded run; on a 20-core machine a 4-megapixel float64 sRGB → Display P3 conversion drops from about
730 ms to 110 ms. Use lcms2.set_threads(1) when you already parallelise at a higher level, and
lcms2.get_threads() to read the setting.
Free-threaded CPython (3.14t) is supported and the module does not re-enable the GIL. Reading a Profile
from many threads is fine; don’t modify one (headers, tags) while another thread uses it.