lcms2.convert¶
- convert(data: Any, src: Any, dst: Any, *, out: ndarray | None = None, out_dtype: DTypeLike = None, **options: Any) ndarray[source]¶
Convert colours from
srctodst.srcanddstmay beProfileobjects, built-in profile names, paths, or colour space objects (anything withto_xyz/from_xyzworking in XYZ D50, Y = 1). Mixed conversions go through XYZ D50. Transforms are cached (LRU) per profile pair and options.- Parameters:
data (array-like or str) –
(..., channels)pixels, or CSS colours ("#ff8000","rebeccapurple","rgb(255 128 0)", or a list of them), which become sRGB floats in 0..1.src (Profile, str, path or colour space) – Source and destination.
dst (Profile, str, path or colour space) – Source and destination.
out – See
Transform.apply().out_dtype – See
Transform.apply().**options –
Transformkeywords:intent,bpc,proof,gamut_check,optimize,precision,flags.
- Returns:
numpy.ndarray – Between two profiles the dtype follows the input (see
Transform.apply()); when a colour space object is involved the result isfloat64, since analytic spaces work in floats. Passout_dtypeto choose.
Examples
>>> import lcms2 >>> lcms2.convert([255, 255, 255], "sRGB", "Lab").round(2) + 0.0 array([100., 0., 0.]) >>> lcms2.convert([[1.0, 0.0, 0.0]], "sRGB", "Display P3").round(3) array([[0.917, 0.2 , 0.139]]) >>> lcms2.convert("#ffffff", "sRGB", "Lab").round(2) + 0.0 array([100., 0., 0.])