{"record":{"id":"16b9d0ab87fc9be1","repo":"SixLabors/ImageSharp","slug":"icc-conversion-supports-at-most-four-input-and-output-16b9d0","errorCode":null,"errorMessage":"ICC conversion supports at most four input and output channels.","messagePattern":"ICC conversion supports at most four input and output channels\\.","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs","lineNumber":64,"sourceCode":"    }\n\n    [MethodImpl(MethodImplOptions.AggressiveInlining)]\n    private static Vector4 CalculateLut(LutCalculator[] lut, Vector4 value)\n    {\n        ref float f = ref Unsafe.As<Vector4, float>(ref value);\n        for (int i = 0; i < lut.Length; i++)\n        {\n            Unsafe.Add(ref f, i) = lut[i].Calculate(Unsafe.Add(ref f, i));\n        }\n\n        return value;\n    }\n\n    private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matrix4x4 matrix)\n    {\n        if (inputCurve.Length > 4 || outputCurve.Length > 4)\n        {\n            throw new InvalidIccProfileException(\"ICC conversion supports at most four input and output channels.\");\n        }\n\n        this.inputCurve = InitLut(inputCurve);\n        this.outputCurve = InitLut(outputCurve);\n        this.clutCalculator = new ClutCalculator(clut);\n        this.matrix = matrix;\n\n        this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3;\n    }\n\n    private static LutCalculator[] InitLut(IccLut[] curves)\n    {\n        LutCalculator[] calculators = new LutCalculator[curves.Length];\n        for (int i = 0; i < curves.Length; i++)\n        {\n            calculators[i] = new LutCalculator(curves[i].Values, false);\n        }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs#L46-L82","documentation":"LutEntryCalculator.Init validates that the matrix/TRC LUT entry has at most 4 input and 4 output curve arrays before wiring up the curve, CLUT and matrix calculators, throwing InvalidIccProfileException otherwise. Like ClutCalculator, the implementation is limited to 4-channel device spaces (RGB, CMYK, Gray).","triggerScenarios":"Converting with an ICC profile whose mft1/mft2 (Lut8/Lut16) or similar LutEntry tags declare more than 4 input or output curves — i.e. an N-channel (>CMYK) or malformed profile.","commonSituations":"Loading exotic or corrupt ICC profiles; profiles produced by buggy generators that emit wrong curve counts; profiles for HiFi printing spaces (e.g. 6-channel) unsupported here.","solutions":["Use a standard 3/4-channel ICC profile for the source or target space.","Pre-validate the profile's LUT curve counts and reject >4 before constructing the converter.","Convert via an external ICC engine (littleCMS, OS color management) if >4 channels is required."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (inputCurve.Length > 4 || outputCurve.Length > 4)\n{\n    throw new NotSupportedException(\"ICC LUT entry exceeds 4 channels; unsupported.\");\n}","typeGuard":null,"tryCatchPattern":"try { converter.Convert(...); }\ncatch (InvalidIccProfileException ex) { /* reject profile, fall back to a standard sRGB/CMYK profile */ }","preventionTips":["Validate LUT curve counts at profile intake.","Restrict accepted profiles to Gray/RGB/CMYK device spaces.","Use trusted profile vendors and verify profiles after download."],"tags":["icc","color-management","profile-validation","csharp"],"backgroundTag":"invalid-argument-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"}