SixLabors/ImageSharp · error · InvalidIccProfileException

ParametricCurve

Error message

ParametricCurve

What it means

ParametricCurveCalculator.Calculate throws InvalidIccProfileException("ParametricCurve") when the parametric curve type (including inversion flag) matches no known ICC parametric curve type (Type0–Type5 / Cie122-1996 / Iec61966-3 / SRgb and their inverted forms). The profile contains a para tag whose curve type value is outside the ICC specification set.

Solutions

  1. Replace or re-export the ICC profile with a standard tool so para tags use valid types 0–5.
  2. Pre-validate parametric curve type codes before conversion and reject invalid profiles.
  3. Report a library bug if the type value is within the ICC spec but still rejected.
Defensive patterns

Strategy: try-catch

Try / catch

try { converter.Convert(...); }
catch (InvalidIccProfileException ex) when (ex.Message == "ParametricCurve") { logger.LogWarning(ex, "Profile contains invalid parametric curve type"); /* substitute a standard profile */ }

Prevention

When it happens

Trigger: Converting with an ICC profile whose parametricCurveType tag data carries an unrecognized type code (e.g. >5 or reserved values), then invoking the TRC/Calculate path.

Common situations: Corrupt or truncated 'para' tag data; profiles written by buggy encoders that emit wrong type bytes; hand-crafted profiles for testing.

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/91096179a6bb15d9. Report an issue: GitHub.

Appendix: source

Thrown at src/ImageSharp/ColorProfiles/Icc/Calculators/ParametricCurveCalculator.cs:40

        {
            this.type |= InvertedFlag;
        }
    }

    public float Calculate(float value)
        => this.type switch
        {
            IccParametricCurveType.Type1 => this.CalculateGamma(value),
            IccParametricCurveType.Cie122_1996 => this.CalculateCie122(value),
            IccParametricCurveType.Iec61966_3 => this.CalculateIec61966(value),
            IccParametricCurveType.SRgb => this.CalculateSRgb(value),
            IccParametricCurveType.Type5 => this.CalculateType5(value),
            IccParametricCurveType.Type1 | InvertedFlag => this.CalculateInvertedGamma(value),
            IccParametricCurveType.Cie122_1996 | InvertedFlag => this.CalculateInvertedCie122(value),
            IccParametricCurveType.Iec61966_3 | InvertedFlag => this.CalculateInvertedIec61966(value),
            IccParametricCurveType.SRgb | InvertedFlag => this.CalculateInvertedSRgb(value),
            IccParametricCurveType.Type5 | InvertedFlag => this.CalculateInvertedType5(value),
            _ => throw new InvalidIccProfileException("ParametricCurve"),
        };

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private float CalculateGamma(float value) => MathF.Pow(value, this.curve.G);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private float CalculateCie122(float value)
    {
        if (value >= -this.curve.B / this.curve.A)
        {
            return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G);
        }

        return 0;
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private float CalculateIec61966(float value)

View on GitHub (pinned to 59ce6af6fc)