cutcutcodec.core.classes.colorspace.Colorspace

class cutcutcodec.core.classes.colorspace.Colorspace(space: str | Self, primaries: str | None = None, transfer: str | None = None)[source]

Structure to ensure color space consistency.

See cutcutcodec.core.colorspace for more details and explanations.

Attributes

spacestr

The main space name, one of « y’pbpr », « r’g’b” », « rgb », « xyz ». It is defined in cutcutcodec.core.colorspace.cst.SYMBS.

primariesstr or None

The tristimulus primaries colors name (gamut). All available values are the keys of cutcutcodec.core.colorspace.cst.PRIMARIES, defined in the module cutcutcodec.core.colorspace.cst.

symbolstuple[sympy.Symbol, sympy.Symbol, sympy.Symbol]

The sympy symbols used as input of the expression given by the methode to.

transferstr or None

The non-linear transfer function name (gamma). All available values are the keys of cutcutcodec.core.colorspace.cst.TRC, defined in the module cutcutcodec.core.colorspace.cst.

Parse the colorspace.

Parameters

spaceColorspace | str

The colorspace formatted as {name}[_{colorspace}], with name in « y’pbpr », « r’g’b” », « rgb », « xyz » (readonly). When several names are given, the first matching in alphabetic order is taken.

primariesstr, optional

If supplied, this is given priority over space for the gamut (read and write).

transferstr, optional

If supplied, this is given priority over space for the gamma (read and write).

classmethod from_default_target() Self[source]

Create the default y’pbpr working colorspace.

The default primaries and transfer are taken from the attributes target_prim and target_trc of the class cutcutcodec.config.config.Config.

The default value can be overwitten in the file ~/.config/cutcutcodec/conf.ini

Examples

>>> from cutcutcodec.core.classes.colorspace import Colorspace
>>> Colorspace.from_default_target()
Colorspace("y'pbpr", 'bt709', 'iec61966-2-1, iec61966_2_1')
>>>
classmethod from_default_target_rgb() Self[source]

Construct same as from_default_target in r’g’b” space.

classmethod from_default_working() Self[source]

Create the default rgb working colorspace.

The default primaries is taken from the attribute working_prim of the class cutcutcodec.config.config.Config.

The default value can be overwitten in the file ~/.config/cutcutcodec/conf.ini

Examples

>>> from cutcutcodec.core.classes.colorspace import Colorspace
>>> Colorspace.from_default_working()
Colorspace('rgb', 'bt709')
>>>
property primaries: None | str

Return the gamut name.

property space: str

Return the main colorspace name.

property symbols: tuple[Symbol, Symbol, Symbol]

Return the space symbols.

to(dst: Self | str) tuple[Basic, Basic, Basic][source]

Alias to cutcutcodec.core.colorspace.func.convert().

property transfer: None | str

Return the gamut name.