{"record":{"id":"75cc7aad5e2261ee","repo":"SixLabors/ImageSharp","slug":"unrecognized-colorant-encoding","errorCode":null,"errorMessage":"Unrecognized colorant encoding","messagePattern":"Unrecognized colorant encoding","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs","lineNumber":143,"sourceCode":"                    [0.300, 0.600],\n                    [0.150, 0.060]\n                ];\n            case IccColorantEncoding.P22:\n                return\n                [\n                    [0.625, 0.340],\n                    [0.280, 0.605],\n                    [0.155, 0.070]\n                ];\n            case IccColorantEncoding.SmpteRp145:\n                return\n                [\n                    [0.630, 0.340],\n                    [0.310, 0.595],\n                    [0.155, 0.070]\n                ];\n            default:\n                throw new InvalidIccProfileException(\"Unrecognized colorant encoding\");\n        }\n    }\n\n    private bool EqualsChannelValues(IccChromaticityTagDataEntry entry)\n    {\n        if (this.ChannelValues.Length != entry.ChannelValues.Length)\n        {\n            return false;\n        }\n\n        for (int i = 0; i < this.ChannelValues.Length; i++)\n        {\n            if (!this.ChannelValues[i].AsSpan().SequenceEqual(entry.ChannelValues[i]))\n            {\n                return false;\n            }\n        }\n","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs#L125-L161","documentation":"IccChromaticityTagDataEntry resolves colorant coordinates only for known colorant encodings (e.g. RGB, CMYK derived from the channel count / colorant type). When the stored colorant value does not map to any known encoding, the entry construction throws InvalidIccProfileException with 'Unrecognized colorant encoding'.","triggerScenarios":"Constructing an IccChromaticityTagDataEntry (or Equals/GetColorantArray path) with a colorant/channel specification that does not match any supported encoding, e.g. an unexpected ColorantEncoding value combined with a channel count not covered by the switch in GetColorantArray.","commonSituations":"Loading a malformed or non-standard ICC profile whose chromaticity tag carries an encoding outside the ICC spec subset ImageSharp supports; hand-crafting a chromaticity tag with a wrong channel value.","solutions":["Check the colorant encoding/channel count on the source profile; only RGB and CMYK-style chromaticity encodings are supported","Fix or regenerate the profile with a standard tool so the chromaticity tag uses a known encoding","If you only need the raw bytes, read the tag data directly instead of constructing the typed entry","Catch InvalidIccProfileException when loading untrusted profiles and fall back to ignoring the chromaticity tag"],"exampleFix":"// before\nvar entry = new IccChromaticityTagDataEntry((IccColorantEncoding)0x99, channelValues);\n// after\nif (Enum.IsDefined(typeof(IccColorantEncoding), encoding) && encoding != IccColorantEncoding.Unknown)\n{\n    var entry = new IccChromaticityTagDataEntry(encoding, channelValues);\n}","handlingStrategy":"try-catch","validationCode":"bool known = colorant is IccColorantEncoding.Rgb or IccColorantEncoding.Cmy or IccColorantEncoding.Cmyk or IccColorantEncoding.CmykChannel1 or IccColorantEncoding.CmykChannel2 or IccColorantEncoding.CmykChannel3;","typeGuard":"static bool IsKnownColorant(IccColorantEncoding e) => e is not IccColorantEncoding.Unknown && Enum.IsDefined(e);","tryCatchPattern":"try { var entry = new IccChromaticityTagDataEntry(encoding, values); } catch (InvalidIccProfileException ex) { log.Warn(ex, \"Unrecognized chromaticity colorant; skipping tag\"); }","preventionTips":["Only load chromaticity tags with RGB/CMYK-style encodings","Validate untrusted profiles before constructing typed entries","Handle profiles from non-conformant sources defensively"],"tags":["icc","chromaticity","validation"],"backgroundTag":"invalid-enum-value","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"}