Skip to content

Added missing gray ICC - #26

Closed
svera wants to merge 2 commits into
kovidgoyal:masterfrom
svera:fix-gray-icc
Closed

svera wants to merge 2 commits into
kovidgoyal:masterfrom
svera:fix-gray-icc

Conversation

@svera

@svera svera commented Sep 24, 2026 •

Copy link
Copy Markdown

Problem

imaging's ICC parser (prism/meta/icc) rejected Gray colorspace profiles: the header validator only allowed RGB/CMYK, and the matrix/TRC transformer builder only knew how to build RGB (3-curve + colorant matrix) pipelines. Since autometa.Load parses ICC metadata before pixel decoding, any Gray-profile image would fail. You can check the problem with this image: https://www.wikidata.org/wiki/Q54883642#/media/File:Paloma-S%C3%A1nchez-Garnica.jpg

Changes

  • profilereader.go: accept ColorSpaceGray in header validation.
  • tagtable.go: added load_media_white_point() to read the wtpt tag (also reused by get_effective_chromatic_adaption).
  • pcs.go: added GrayToXYZ / XYZToGray transformer types implementing the ICC monochrome matrix/TRC model — an achromatic value is scaled by the media white point to produce (or is recovered from) PCS XYZ.
  • profile.go: create_matrix_trc_transformer now delegates to a new create_gray_trc_transformer for Gray profiles, using the kTRC curve plus white-point scaling instead of the RGB colorant matrix.
  • profile_gray_test.go: new test building a synthetic Gray ICC profile (parametric gamma kTRC + wtpt) and verifying decode + round-trip gray → PCS → gray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant