SixLabors/ImageSharp · error · InvalidIccProfileException

Invalid parametric curve type of

Error message

Invalid parametric curve type of {type}

What it means

When reading an ICC profile's parametric curve tag, ReadParametricCurve switches on the curve function type byte (valid ICC values 0-4). Any other value means the profile violates the ICC spec, so InvalidIccProfileException is thrown. Valid types: 0 (gamma), 1 (gamma,a,b), 2 (+c), 3 (+d), 4 (full g,a,b,c,d,e,f).

Solutions

  1. Strip or replace the ICC profile: re-save the image with a known-good profile (e.g. sRGB) using ImageMagick or similar.
  2. Catch InvalidIccProfileException and fall back to processing without color management if exact colors are noncritical.
  3. Validate the source profile with a tool like ICC Profile Inspector to confirm it is the culprit.

Example fix

// before
using var image = Image.Load(path); // throws on bad ICC parametric curve
// after
try
{
    using var image = Image.Load(path);
}
catch (InvalidIccProfileException ex)
{
    logger.LogWarning("Invalid ICC profile: {Msg}", ex.Message);
    using var image = Image.Load(new DecoderOptions(), path); // fallback handling
}
Defensive patterns

Strategy: fallback

Try / catch

try { using var image = Image.Load(path); }
catch (InvalidIccProfileException ex) when (ex.Message.Contains("parametric curve"))
{ /* fall back: load ignoring the ICC profile or replace it with sRGB */ }

Prevention

When it happens

Trigger: Loading an image whose embedded ICC profile contains a parametricCurveType tag data entry with function type outside 0-4 — corrupt profiles or profiles written by nonconformant tools.

Common situations: Images with damaged or hand-edited ICC profiles; device profiles produced by buggy color-management tools; fuzzed images with random tag data.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs:114

        if (type > 2 && type <= 4)
        {
            d = this.ReadFix16();
        }

        if (type == 4)
        {
            e = this.ReadFix16();
            f = this.ReadFix16();
        }

        switch (type)
        {
            case 0: return new IccParametricCurve(gamma);
            case 1: return new IccParametricCurve(gamma, a, b);
            case 2: return new IccParametricCurve(gamma, a, b, c);
            case 3: return new IccParametricCurve(gamma, a, b, c, d);
            case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f);
            default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}");
        }
    }

    /// <summary>
    /// Reads a <see cref="IccCurveSegment"/>
    /// </summary>
    /// <returns>The read segment</returns>
    public IccCurveSegment ReadCurveSegment()
    {
        IccCurveSegmentSignature signature = (IccCurveSegmentSignature)this.ReadUInt32();
        this.AddIndex(4);   // 4 bytes reserved

        switch (signature)
        {
            case IccCurveSegmentSignature.FormulaCurve:
                return this.ReadFormulaCurveElement();
            case IccCurveSegmentSignature.SampledCurve:
                return this.ReadSampledCurveElement();

View on GitHub (pinned to 59ce6af6fc)