SixLabors/ImageSharp · error · InvalidIccProfileException

Missing matrix column or channel.

Error message

Missing matrix column or channel.

What it means

InitColorTrc requires all nine tags of the matrix/TRC color pipeline — red/green/blue matrix column XYZ entries and red/green/blue TRC curve entries — to be present; if any is null the profile is rejected as invalid. Matrix/TRC profiles (typical RGB display profiles) are unusable without a complete set.

Solutions

  1. Supply a complete RGB matrix/TRC ICC profile (sRGB, Adobe RGB, Display P3) that includes all rXYZ/gXYZ/bXYZ and rTRC/gTRC/bTRC tags.
  2. Verify the profile loads fully and the tags are present before constructing the converter.
  3. For CMYK/LUT-based workflows use the A2B path with a LUT profile instead of the matrix/TRC path.
  4. Catch InvalidIccProfileException and fall back to a known-good embedded profile.

Example fix

// before: passing a profile missing bTRC
var converter = new IccConverter(brokenDisplayProfile);
// after: validate required tags first
bool hasTrc = profile.Tags.ContainsKey(IccProfileTag.RedTrc)
           && profile.Tags.ContainsKey(IccProfileTag.GreenTrc)
           && profile.Tags.ContainsKey(IccProfileTag.BlueTrc);
var converter = hasTrc ? new IccConverter(profile) : new IccConverter(KnownIccProfiles.SRgb);
Defensive patterns

Strategy: validation

Validate before calling

static bool HasFullMatrixTrc(IccProfile p) =>
    p.Tags.ContainsKey(IccProfileTag.RedMatrixColumn) &&
    p.Tags.ContainsKey(IccProfileTag.GreenMatrixColumn) &&
    p.Tags.ContainsKey(IccProfileTag.BlueMatrixColumn) &&
    p.Tags.ContainsKey(IccProfileTag.RedTrc) &&
    p.Tags.ContainsKey(IccProfileTag.GreenTrc) &&
    p.Tags.ContainsKey(IccProfileTag.BlueTrc);

Try / catch

try { converter = new IccConverter(profile); }
catch (InvalidIccProfileException ex) when (ex.Message.Contains("matrix"))
{ converter = new IccConverter(KnownIccProfiles.SRgb); }

Prevention

When it happens

Trigger: Building a converter from an ICC profile whose rXYZ/gXYZ/bXYZ or rTRC/gTRC/bTRC tags are missing, e.g. truncated profiles, device-link or abstract profiles that don't carry matrix/TRC tags, or profiles parsed with dropped entries.

Common situations: Hand-edited or stripped ICC profiles; using an N-channel (CMYK) or LUT-only profile where the caller expects the matrix/TRC path; profiles from unusual colorants missing some channel curves.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13). Data as JSON: /api/errors/505935e61f76b436. Report an issue: GitHub.

Appendix: source

Thrown at src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs:91

    private static ColorTrcCalculator InitColorTrc(IccProfile profile, bool toPcs)
    {
        IccXyzTagDataEntry redMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.RedMatrixColumn);
        IccXyzTagDataEntry greenMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.GreenMatrixColumn);
        IccXyzTagDataEntry blueMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.BlueMatrixColumn);

        IccTagDataEntry redTrc = GetTag(profile, IccProfileTag.RedTrc);
        IccTagDataEntry greenTrc = GetTag(profile, IccProfileTag.GreenTrc);
        IccTagDataEntry blueTrc = GetTag(profile, IccProfileTag.BlueTrc);

        if (redMatrixColumn == null ||
            greenMatrixColumn == null ||
            blueMatrixColumn == null ||
            redTrc == null ||
            greenTrc == null ||
            blueTrc == null)
        {
            throw new InvalidIccProfileException("Missing matrix column or channel.");
        }

        return new ColorTrcCalculator(
            redMatrixColumn,
            greenMatrixColumn,
            blueMatrixColumn,
            redTrc,
            greenTrc,
            blueTrc,
            toPcs);
    }

    private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs)
    {
        IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc);
        return new GrayTrcCalculator(entry, toPcs);
    }
}

View on GitHub (pinned to 59ce6af6fc)