{"record":{"id":"505935e61f76b436","repo":"SixLabors/ImageSharp","slug":"missing-matrix-column-or-channel","errorCode":null,"errorMessage":"Missing matrix column or channel.","messagePattern":"Missing matrix column or channel\\.","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs","lineNumber":91,"sourceCode":"\n    private static ColorTrcCalculator InitColorTrc(IccProfile profile, bool toPcs)\n    {\n        IccXyzTagDataEntry redMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.RedMatrixColumn);\n        IccXyzTagDataEntry greenMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.GreenMatrixColumn);\n        IccXyzTagDataEntry blueMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.BlueMatrixColumn);\n\n        IccTagDataEntry redTrc = GetTag(profile, IccProfileTag.RedTrc);\n        IccTagDataEntry greenTrc = GetTag(profile, IccProfileTag.GreenTrc);\n        IccTagDataEntry blueTrc = GetTag(profile, IccProfileTag.BlueTrc);\n\n        if (redMatrixColumn == null ||\n            greenMatrixColumn == null ||\n            blueMatrixColumn == null ||\n            redTrc == null ||\n            greenTrc == null ||\n            blueTrc == null)\n        {\n            throw new InvalidIccProfileException(\"Missing matrix column or channel.\");\n        }\n\n        return new ColorTrcCalculator(\n            redMatrixColumn,\n            greenMatrixColumn,\n            blueMatrixColumn,\n            redTrc,\n            greenTrc,\n            blueTrc,\n            toPcs);\n    }\n\n    private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs)\n    {\n        IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc);\n        return new GrayTrcCalculator(entry, toPcs);\n    }\n}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Supply a complete RGB matrix/TRC ICC profile (sRGB, Adobe RGB, Display P3) that includes all rXYZ/gXYZ/bXYZ and rTRC/gTRC/bTRC tags.","Verify the profile loads fully and the tags are present before constructing the converter.","For CMYK/LUT-based workflows use the A2B path with a LUT profile instead of the matrix/TRC path.","Catch InvalidIccProfileException and fall back to a known-good embedded profile."],"exampleFix":"// before: passing a profile missing bTRC\nvar converter = new IccConverter(brokenDisplayProfile);\n// after: validate required tags first\nbool hasTrc = profile.Tags.ContainsKey(IccProfileTag.RedTrc)\n           && profile.Tags.ContainsKey(IccProfileTag.GreenTrc)\n           && profile.Tags.ContainsKey(IccProfileTag.BlueTrc);\nvar converter = hasTrc ? new IccConverter(profile) : new IccConverter(KnownIccProfiles.SRgb);","handlingStrategy":"validation","validationCode":"static bool HasFullMatrixTrc(IccProfile p) =>\n    p.Tags.ContainsKey(IccProfileTag.RedMatrixColumn) &&\n    p.Tags.ContainsKey(IccProfileTag.GreenMatrixColumn) &&\n    p.Tags.ContainsKey(IccProfileTag.BlueMatrixColumn) &&\n    p.Tags.ContainsKey(IccProfileTag.RedTrc) &&\n    p.Tags.ContainsKey(IccProfileTag.GreenTrc) &&\n    p.Tags.ContainsKey(IccProfileTag.BlueTrc);","typeGuard":null,"tryCatchPattern":"try { converter = new IccConverter(profile); }\ncatch (InvalidIccProfileException ex) when (ex.Message.Contains(\"matrix\"))\n{ converter = new IccConverter(KnownIccProfiles.SRgb); }","preventionTips":["Ship complete RGB matrix/TRC profiles (sRGB, Adobe RGB) in your app.","Reject stripped or hand-edited profiles at ingestion time.","Use LUT-based profiles for CMYK workflows instead of expecting matrix/TRC tags."],"tags":["icc","color-profile","matrix-trc","missing-tag"],"backgroundTag":"missing-required-argument","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}