ImageCms Module

The ImageCms module provides color profile management support using the LittleCMS2 color management engine, based on Kevin Cazabon’s PyCMS library.

Functions

CmsProfile

The ICC color profiles are wrapped in an instance of the class CmsProfile. The specification ICC.1:2010 contains more information about the meaning of the values in ICC profiles.

For convenience, all XYZ-values are also given as xyY-values (so they can be easily displayed in a chromaticity diagram, for example).

class PIL.ImageCms.CmsProfile
creation_date: Optional[datetime.datetime]

Date and time this profile was first created (see 7.2.1 of ICC.1:2010).

version: float

The version number of the ICC standard that this profile follows (e.g. 2.0).

icc_version: int

Same as version, but in encoded format (see 7.2.4 of ICC.1:2010).

device_class: str

4-character string identifying the profile class. One of scnr, mntr, prtr, link, spac, abst, nmcl (see 7.2.5 of ICC.1:2010 for details).

xcolor_space: str

4-character string (padded with whitespace) identifying the color space, e.g. XYZ␣, RGB␣ or CMYK (see 7.2.6 of ICC.1:2010 for details).

connection_space: str

4-character string (padded with whitespace) identifying the color space on the B-side of the transform (see 7.2.7 of ICC.1:2010 for details).

header_flags: int

The encoded header flags of the profile (see 7.2.11 of ICC.1:2010 for details).

header_manufacturer: str

4-character string (padded with whitespace) identifying the device manufacturer, which shall match the signature contained in the appropriate section of the ICC signature registry found at www.color.org (see 7.2.12 of ICC.1:2010).

header_model: str

4-character string (padded with whitespace) identifying the device model, which shall match the signature contained in the appropriate section of the ICC signature registry found at www.color.org (see 7.2.13 of ICC.1:2010).

attributes: int

Flags used to identify attributes unique to the particular device setup for which the profile is applicable (see 7.2.14 of ICC.1:2010 for details).

rendering_intent: int

The rendering intent to use when combining this profile with another profile (usually overridden at run-time, but provided here for DeviceLink and embedded source profiles, see 7.2.15 of ICC.1:2010).

One of ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Intent.PERCEPTUAL, ImageCms.Intent.RELATIVE_COLORIMETRIC and ImageCms.Intent.SATURATION.

profile_id: bytes

A sequence of 16 bytes identifying the profile (via a specially constructed MD5 sum), or 16 binary zeroes if the profile ID has not been calculated (see 7.2.18 of ICC.1:2010).

copyright: Optional[str]

The text copyright information for the profile (see 9.2.21 of ICC.1:2010).

manufacturer: Optional[str]

The (English) display string for the device manufacturer (see 9.2.22 of ICC.1:2010).

model: Optional[str]

The (English) display string for the device model of the device for which this profile is created (see 9.2.23 of ICC.1:2010).

profile_description: Optional[str]

The (English) display string for the profile description (see 9.2.41 of ICC.1:2010).

target: Optional[str]

The name of the registered characterization data set, or the measurement data for a characterization target (see 9.2.14 of ICC.1:2010).

red_colorant: Optional[tuple[tuple[float]]]

The first column in the matrix used in matrix/TRC transforms (see 9.2.44 of ICC.1:2010).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

green_colorant: Optional[tuple[tuple[float]]]

The second column in the matrix used in matrix/TRC transforms (see 9.2.30 of ICC.1:2010).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

blue_colorant: Optional[tuple[tuple[float]]]

The third column in the matrix used in matrix/TRC transforms (see 9.2.4 of ICC.1:2010).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

luminance: Optional[tuple[tuple[float]]]

The absolute luminance of emissive devices in candelas per square metre as described by the Y channel (see 9.2.32 of ICC.1:2010).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

chromaticity: Optional[tuple[tuple[float]]]

The data of the phosphor/colorant chromaticity set used (red, green and blue channels, see 9.2.16 of ICC.1:2010).

The value is in the format ((x, y, Y), (x, y, Y), (x, y, Y)), if available.

chromatic_adaption: tuple[tuple[float]]

The chromatic adaption matrix converts a color measured using the actual illumination conditions and relative to the actual adopted white, to a color relative to the PCS adopted white, with complete adaptation from the actual adopted white chromaticity to the PCS adopted white chromaticity (see 9.2.15 of ICC.1:2010).

Two 3-tuples of floats are returned in a 2-tuple, one in (X, Y, Z) space and one in (x, y, Y) space.

colorant_table: list[str]

This tag identifies the colorants used in the profile by a unique name and set of PCSXYZ or PCSLAB values (see 9.2.19 of ICC.1:2010).

colorant_table_out: list[str]

This tag identifies the colorants used in the profile by a unique name and set of PCSLAB values (for DeviceLink profiles only, see 9.2.19 of ICC.1:2010).

colorimetric_intent: Optional[str]

4-character string (padded with whitespace) identifying the image state of PCS colorimetry produced using the colorimetric intent transforms (see 9.2.20 of ICC.1:2010 for details).

perceptual_rendering_intent_gamut: Optional[str]

4-character string (padded with whitespace) identifying the (one) standard reference medium gamut (see 9.2.37 of ICC.1:2010 for details).

saturation_rendering_intent_gamut: Optional[str]

4-character string (padded with whitespace) identifying the (one) standard reference medium gamut (see 9.2.37 of ICC.1:2010 for details).

technology: Optional[str]

4-character string (padded with whitespace) identifying the device technology (see 9.2.47 of ICC.1:2010 for details).

media_black_point: Optional[tuple[tuple[float]]]

This tag specifies the media black point and is used for generating absolute colorimetry.

This tag was available in ICC 3.2, but it is removed from version 4.

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

media_white_point_temperature: Optional[float]

Calculates the white point temperature (see the LCMS documentation for more information).

viewing_condition: Optional[str]

The (English) display string for the viewing conditions (see 9.2.48 of ICC.1:2010).

screening_description: Optional[str]

The (English) display string for the screening conditions.

This tag was available in ICC 3.2, but it is removed from version 4.

red_primary: Optional[tuple[tuple[float]]]

The XYZ-transformed of the RGB primary color red (1, 0, 0).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

green_primary: Optional[tuple[tuple[float]]]

The XYZ-transformed of the RGB primary color green (0, 1, 0).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

blue_primary: Optional[tuple[tuple[float]]]

The XYZ-transformed of the RGB primary color blue (0, 0, 1).

The value is in the format ((X, Y, Z), (x, y, Y)), if available.

is_matrix_shaper: bool

True if this profile is implemented as a matrix shaper (see documentation on LCMS).

clut: dict[tuple[bool]]

Returns a dictionary of all supported intents and directions for the CLUT model.

The dictionary is indexed by intents (ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Intent.PERCEPTUAL, ImageCms.Intent.RELATIVE_COLORIMETRIC and ImageCms.Intent.SATURATION).

The values are 3-tuples indexed by directions (ImageCms.Direction.INPUT, ImageCms.Direction.OUTPUT, ImageCms.Direction.PROOF).

The elements of the tuple are booleans. If the value is True, that intent is supported for that direction.

intent_supported: dict[tuple[bool]]

Returns a dictionary of all supported intents and directions.

The dictionary is indexed by intents (ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Intent.PERCEPTUAL, ImageCms.Intent.RELATIVE_COLORIMETRIC and ImageCms.Intent.SATURATION).

The values are 3-tuples indexed by directions (ImageCms.Direction.INPUT, ImageCms.Direction.OUTPUT, ImageCms.Direction.PROOF).

The elements of the tuple are booleans. If the value is True, that intent is supported for that direction.

There is one function defined on the class:

is_intent_supported(intent, direction)

Returns if the intent is supported for the given direction.

Note that you can also get this information for all intents and directions with intent_supported.

Parameters:
  • intent – One of ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Intent.PERCEPTUAL, ImageCms.Intent.RELATIVE_COLORIMETRIC and ImageCms.Intent.SATURATION.

  • direction – One of ImageCms.Direction.INPUT, ImageCms.Direction.OUTPUT and ImageCms.Direction.PROOF

Returns:

Boolean if the intent and direction is supported.