SixLabors/ImageSharp · error · InvalidIccProfileException

ICC conversion supports at most four input and output…

Error message

ICC conversion supports at most four input and output channels.

What it means

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).

Solutions

  1. Use a standard 3/4-channel ICC profile for the source or target space.
  2. Pre-validate the profile's LUT curve counts and reject >4 before constructing the converter.
  3. Convert via an external ICC engine (littleCMS, OS color management) if >4 channels is required.
Defensive patterns

Strategy: validation

Validate before calling

if (inputCurve.Length > 4 || outputCurve.Length > 4)
{
    throw new NotSupportedException("ICC LUT entry exceeds 4 channels; unsupported.");
}

Try / catch

try { converter.Convert(...); }
catch (InvalidIccProfileException ex) { /* reject profile, fall back to a standard sRGB/CMYK profile */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs:64

    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private static Vector4 CalculateLut(LutCalculator[] lut, Vector4 value)
    {
        ref float f = ref Unsafe.As<Vector4, float>(ref value);
        for (int i = 0; i < lut.Length; i++)
        {
            Unsafe.Add(ref f, i) = lut[i].Calculate(Unsafe.Add(ref f, i));
        }

        return value;
    }

    private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matrix4x4 matrix)
    {
        if (inputCurve.Length > 4 || outputCurve.Length > 4)
        {
            throw new InvalidIccProfileException("ICC conversion supports at most four input and output channels.");
        }

        this.inputCurve = InitLut(inputCurve);
        this.outputCurve = InitLut(outputCurve);
        this.clutCalculator = new ClutCalculator(clut);
        this.matrix = matrix;

        this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3;
    }

    private static LutCalculator[] InitLut(IccLut[] curves)
    {
        LutCalculator[] calculators = new LutCalculator[curves.Length];
        for (int i = 0; i < curves.Length; i++)
        {
            calculators[i] = new LutCalculator(curves[i].Values, false);
        }

View on GitHub (pinned to 59ce6af6fc)