ColorProfile

class ColorProfile(val icc: ByteArray? = null, val iccName: String? = null, val srgbIntent: Int? = null, val gamma: Int? = null, val chromaticities: IntArray? = null, val cicp: IntArray? = null, val contentLight: IntArray? = null, val masteringDisplay: IntArray? = null)(source)

What a file declares about the color space of its samples, as it declares it: ImageInfo.colorProfile reports it, and a decode with ColorTarget.Srgb or ImageKodec.convertToSrgb converts through it. Nearly every image is sRGB and says so or says nothing; the rest, such as a Display P3 photo or an Adobe RGB scan, draw with the wrong colors unless they are converted.

  • icc is the embedded ICC profile, byte for byte as the file holds it once decompressed or reassembled: PNG iCCP, JPEG APP2 ICC_PROFILE segments in sequence order, TIFF tag 34675, WebP ICCP, JPEG 2000 colr methods 2 and 3, a BMP V5 header's embedded profile, GIF's ICCRGBG1012 application extension.

  • iccName, srgbIntent, gamma, chromaticities and cicp are PNG's own chunks: the iCCP profile name, sRGB's rendering intent (0 perceptual, 1 relative colorimetric, 2 saturation, 3 absolute colorimetric), gAMA's gamma times 100000 (45455 for the usual 1/2.2), cHRM's white point, red, green and blue x and y times 100000, and cICP's color primaries, transfer function, matrix coefficients and full-range flag (ITU-T H.273 code points). An AVIF's nclx colour box, or its AV1 sequence header, gives cicp too, and so does the colour encoding a JPEG XL header names.

  • contentLight and masteringDisplay describe HDR content: PNG's cLLi and mDCv chunks, or an AVIF's clli and mdcv boxes. contentLight holds the maximum content light level and the maximum frame-average light level in 0.0001 cd/m², and masteringDisplay the mastering display's red, green and blue x and y and its white x and y in 0.00002, then its maximum and minimum luminance in 0.0001 cd/m², as both formats store them.

Every field is null when the file does not hold it.

A conversion reads them in the order the format sets. A PNG's cICP comes first, then iCCP, sRGB, and gAMA with cHRM, as the PNG third edition orders them; elsewhere the ICC profile comes before cicp, as AVIF orders them.

Constructors

Link copied to clipboard
constructor(icc: ByteArray? = null, iccName: String? = null, srgbIntent: Int? = null, gamma: Int? = null, chromaticities: IntArray? = null, cicp: IntArray? = null, contentLight: IntArray? = null, masteringDisplay: IntArray? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val gamma: Int?
Link copied to clipboard
Link copied to clipboard

The data color space the profile's header names, trimmed: "RGB", "GRAY", "CMYK", "Lab" and so on; null without a profile or with a header too short.

Link copied to clipboard

The profile's description, such as "Display P3" or "Adobe RGB (1998)", read from its desc tag: v2's ASCII text or v4's first localized string. Null without a profile or when the tag is missing or damaged.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun toString(): String