Skip to content

Add sparse ICC v4 mAB/mBA LUT support for ICC conversion#3070

Merged
JimBobSquarePants merged 2 commits intomainfrom
js/fix-3064
Mar 6, 2026
Merged

Add sparse ICC v4 mAB/mBA LUT support for ICC conversion#3070
JimBobSquarePants merged 2 commits intomainfrom
js/fix-3064

Conversation

@JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #3064

Adds support for valid sparse ICC v4 mAB/mBA pipelines, including transforms such as A -> CLUT -> Matrix.
Updates LUT tag validation to derive channel counts from stage continuity, updates LutABCalculator to execute only the stages present in ICC order, and adds documentation for the new behavior.

This fixes decode failures for embedded ICC profiles like Display P3 PQ profiles.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for sparse ICC v4 mAB/mBA LUT pipelines (eg. A -> CLUT -> Matrix) during ICC-based color conversion to fix decode failures for certain embedded profiles (Issue #3064 / Display P3 PQ).

Changes:

  • Update LutAToB/LutBToA tag validation to derive channel counts from stage continuity (supports sparse stage combinations).
  • Update LutABCalculator to execute only the stages present, in ICC specification order for mAB/mBA.
  • Add a regression test image + reference output for Issue #3064.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Images/Input/Jpg/icc-profiles/issue-3064.jpg Adds regression JPEG containing the problematic embedded ICC profile (LFS).
tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Issue3064_Rgba32_issue-3064.png Adds expected decode output for regression comparison (LFS).
tests/ImageSharp.Tests/TestImages.cs Registers the new ICC regression test image path.
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs Adds a decoder test that exercises ICC conversion for Issue #3064.
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs Reworks LUT stage validation to support sparse mBA pipelines and derive channel counts.
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs Reworks LUT stage validation to support sparse mAB pipelines and derive channel counts.
src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs Minor refactor to use range-based slicing when restoring hash inputs.
src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs Refactors tag entry dispatch to a switch expression; makes a local helper static.
src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs Improves Invalid ICC entry exception message by including the tag.
src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs Applies only present LUT stages in ICC order; removes legacy “fixed combinations” logic.
src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.CalculationType.cs Simplifies calculation type enum to direction-only.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@JimBobSquarePants JimBobSquarePants added this to the v4.0.0 milestone Mar 6, 2026
@JimBobSquarePants JimBobSquarePants merged commit 4bb4baf into main Mar 6, 2026
12 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-3064 branch March 6, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image.LoadAsync throw InvalidIccProfileException

2 participants