SixLabors/ImageSharp · error · InvalidIccProfileException

ICC conversion supports at most four tone response curves.

Error message

ICC conversion supports at most four tone response curves.

What it means

TrcCalculator's constructor accepts an array of tone response curve tag entries (one per channel) and throws InvalidIccProfileException when more than 4 entries are supplied, since the calculator produces a Vector4 (4-channel max) result.

Solutions

  1. Use a profile limited to Gray/RGB/CMYK (≤4 channels).
  2. Validate TRC entry counts before conversion and reject profiles exceeding 4.
  3. Fall back to an external ICC engine for N-channel spaces.
Defensive patterns

Strategy: validation

Validate before calling

if (trcEntries.Length > 4)
{
    throw new NotSupportedException("ICC profile has more than four tone response curves; unsupported.");
}

Try / catch

try { converter.Convert(...); }
catch (InvalidIccProfileException ex) { /* reject N-channel profile, use a standard profile instead */ }

Prevention

When it happens

Trigger: Building an IccConverter whose conversion path resolves more than 4 TRC tag entries for a color transform (e.g. an N-channel profile with 5+ channels), hitting the InitColorTrc path.

Common situations: HiFi / extended-ink ICC profiles (5–8 channel); corrupt profiles with duplicated or garbage TRC tags; unsupported device classes.

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/5375e5f4d01f1950. Report an issue: GitHub.

Appendix: source

Thrown at src/ImageSharp/ColorProfiles/Icc/Calculators/TrcCalculator.cs:20

// Licensed under the Six Labors Split License.

using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorProfiles.Conversion.Icc;
using SixLabors.ImageSharp.Metadata.Profiles.Icc;

namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators;

internal class TrcCalculator : IVector4Calculator
{
    private readonly ISingleCalculator[] calculators;

    public TrcCalculator(IccTagDataEntry[] entries, bool inverted)
    {
        Guard.NotNull(entries, nameof(entries));
        if (entries.Length > 4)
        {
            throw new InvalidIccProfileException("ICC conversion supports at most four tone response curves.");
        }

        this.calculators = new ISingleCalculator[entries.Length];
        for (int i = 0; i < entries.Length; i++)
        {
            this.calculators[i] = entries[i] switch
            {
                IccCurveTagDataEntry curve => new CurveCalculator(curve, inverted),
                IccParametricCurveTagDataEntry parametricCurve => new ParametricCurveCalculator(parametricCurve, inverted),
                _ => throw new InvalidIccProfileException("Invalid Entry."),
            };
        }
    }

    public unsafe Vector4 Calculate(Vector4 value)
    {
        ref float f = ref Unsafe.As<Vector4, float>(ref value);
        for (int i = 0; i < this.calculators.Length; i++)

View on GitHub (pinned to 59ce6af6fc)