icc

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package icc converts through the one family of ICC profile that a PDF actually carries in practice: a matrix/TRC profile, gray or RGB, with an XYZ connection space. §8.6.5.5 lets an ICCBased colour space fall back to its /Alternate, or to a device space chosen by /N, when the profile itself cannot be used — so Parse is deliberately narrow, and every profile it refuses is one the caller (render/native) is expected to draw through that fallback instead.

A LUT-based profile (an A2B/D2B tag) is refused rather than approximated, because a CMM that has one uses it in preference to the matrix and curves, and drawing through the matrix instead would disagree with lcms — which is the CMM pdfium, and therefore the reference this package is measured against, actually runs.

wtpt, chad and every tag besides the colorants and curves are read by nothing here. A matrix/TRC profile's colorants are already D50-relative XYZ, so no white-point adaptation is needed to reach the D50 this package works in. The rendering intent is not read either: pdfium converts every colour at the perceptual intent whatever the PDF asks for — /Perceptual, /RelativeColorimetric and /AbsoluteColorimetric were measured drawing identically — and lcms compensates the black point of every perceptual conversion into its own v4 sRGB profile, so this package compensates it too, always.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Profile

type Profile struct {
	// contains filtered or unexported fields
}

Profile is a parsed matrix/TRC ICC profile: gray with one curve, or RGB with three curves and a colorant matrix, ready to convert into sRGB.

func Parse

func Parse(b []byte) (*Profile, error)

Parse reads an ICC profile and returns a Profile if it is a pure matrix/TRC gray or RGB profile with an XYZ connection space. Every other error message starts "icc: ".

func (*Profile) Components

func (p *Profile) Components() int

Components is 1 for a gray profile and 3 for RGB, the number of values SRGB and a pixel's colour channels are read from.

func (*Profile) Image

func (p *Profile) Image(img *image.NRGBA)

Image converts img to sRGB in place. Alpha is untouched, and a sub-image converts only the rectangle it addresses. An sRGB profile (isSRGB) leaves img as it is.

func (*Profile) SRGB

func (p *Profile) SRGB(c []float64) (r, g, b float64)

SRGB converts one colour, given as p.Components() values in the profile's own space, to sRGB.

Unlike Image, the input is not quantized to 8 bits before conversion: pdfium truncates every component to a byte before it ever reaches lcms, and this does not, so the two agree to within a level for a mid-gamma gray profile and to within about six levels near black for a linear one. An sRGB profile (isSRGB) returns the colour it was given, clamped.

func (*Profile) Translate

func (p *Profile) Translate(c []float64) (r, g, b float64)

Translate converts one colour as pdfium's IccTransform::Translate does, where SRGB converts it exactly: each component truncated to a byte, then Image's conversion, so each channel is a whole 255th. An sRGB profile returns the colour clamped and not quantized, as CPDF_ICCBasedCS::GetRGB does before it would reach the transform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL