{"record":{"id":"0b709f016cef6a42","repo":"SixLabors/ImageSharp","slug":"invalid-parametric-curve-type-of-type","errorCode":null,"errorMessage":"Invalid parametric curve type of {type}","messagePattern":"Invalid parametric curve type of (.+?)","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs","lineNumber":114,"sourceCode":"        if (type > 2 && type <= 4)\n        {\n            d = this.ReadFix16();\n        }\n\n        if (type == 4)\n        {\n            e = this.ReadFix16();\n            f = this.ReadFix16();\n        }\n\n        switch (type)\n        {\n            case 0: return new IccParametricCurve(gamma);\n            case 1: return new IccParametricCurve(gamma, a, b);\n            case 2: return new IccParametricCurve(gamma, a, b, c);\n            case 3: return new IccParametricCurve(gamma, a, b, c, d);\n            case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f);\n            default: throw new InvalidIccProfileException($\"Invalid parametric curve type of {type}\");\n        }\n    }\n\n    /// <summary>\n    /// Reads a <see cref=\"IccCurveSegment\"/>\n    /// </summary>\n    /// <returns>The read segment</returns>\n    public IccCurveSegment ReadCurveSegment()\n    {\n        IccCurveSegmentSignature signature = (IccCurveSegmentSignature)this.ReadUInt32();\n        this.AddIndex(4);   // 4 bytes reserved\n\n        switch (signature)\n        {\n            case IccCurveSegmentSignature.FormulaCurve:\n                return this.ReadFormulaCurveElement();\n            case IccCurveSegmentSignature.SampledCurve:\n                return this.ReadSampledCurveElement();","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs#L96-L132","documentation":"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).","triggerScenarios":"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.","commonSituations":"Images with damaged or hand-edited ICC profiles; device profiles produced by buggy color-management tools; fuzzed images with random tag data.","solutions":["Strip or replace the ICC profile: re-save the image with a known-good profile (e.g. sRGB) using ImageMagick or similar.","Catch InvalidIccProfileException and fall back to processing without color management if exact colors are noncritical.","Validate the source profile with a tool like ICC Profile Inspector to confirm it is the culprit."],"exampleFix":"// before\nusing var image = Image.Load(path); // throws on bad ICC parametric curve\n// after\ntry\n{\n    using var image = Image.Load(path);\n}\ncatch (InvalidIccProfileException ex)\n{\n    logger.LogWarning(\"Invalid ICC profile: {Msg}\", ex.Message);\n    using var image = Image.Load(new DecoderOptions(), path); // fallback handling\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { using var image = Image.Load(path); }\ncatch (InvalidIccProfileException ex) when (ex.Message.Contains(\"parametric curve\"))\n{ /* fall back: load ignoring the ICC profile or replace it with sRGB */ }","preventionTips":["Validate embedded ICC profiles (ICC Profile Inspector / color.org validator) at ingestion.","Replace nonconformant profiles with standard sRGB before processing.","Pin down the origin: profiles from buggy converters are the usual source."],"tags":["icc","color-profile","corrupt-input","parsing"],"backgroundTag":"invalid-enum-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"}