{"record":{"id":"b8a823ce7d7e8b9b","repo":"SixLabors/ImageSharp","slug":"curve-has-to-be-either-icctypesignature-curve-or-b8a823","errorCode":null,"errorMessage":"Curve has to be either \"IccTypeSignature.Curve\" or \"IccTypeSignature.ParametricCurve\" for LutAToB- and LutBToA-TagDataEntries","messagePattern":"Curve has to be either \"IccTypeSignature\\.Curve\" or \"IccTypeSignature\\.ParametricCurve\" for LutAToB- and LutBToA-TagDataEntries","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs","lineNumber":220,"sourceCode":"            this.dataStream.WriteByte(data[i]);\n        }\n\n        return length;\n    }\n\n    /// <summary>\n    /// Writes curve data\n    /// </summary>\n    /// <param name=\"curves\">The curves to write</param>\n    /// <returns>The number of bytes written</returns>\n    private int WriteCurves(IccTagDataEntry[] curves)\n    {\n        int count = 0;\n        foreach (IccTagDataEntry curve in curves)\n        {\n            if (curve.Signature != IccTypeSignature.Curve && curve.Signature != IccTypeSignature.ParametricCurve)\n            {\n                throw new InvalidIccProfileException($\"Curve has to be either \\\"{nameof(IccTypeSignature)}.{nameof(IccTypeSignature.Curve)}\\\" or\" +\n                    $\" \\\"{nameof(IccTypeSignature)}.{nameof(IccTypeSignature.ParametricCurve)}\\\" for LutAToB- and LutBToA-TagDataEntries\");\n            }\n\n            count += this.WriteTagDataEntry(curve);\n            count += this.WritePadding();\n        }\n\n        return count;\n    }\n\n    private void Dispose(bool disposing)\n    {\n        if (!this.isDisposed)\n        {\n            if (disposing)\n            {\n                this.dataStream?.Dispose();\n            }","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs#L202-L238","documentation":"ImageSharp's ICC profile writer requires that every curve in a LutAToB or LutBToA tag data entry has a type signature of either Curve or ParametricCurve. When writing such an entry, WriteCurves iterates the curve list and throws InvalidIccProfileException if any entry has another signature (e.g. a multiLocalizedUnicode or text entry accidentally placed in the curve list).","triggerScenarios":"Calling WriteTagDataEntry on an IccLutAtoBTagDataEntry or IccLutBToATagDataEntry whose ATobB curves collection (curvesM, curvesA, or curvesB) contains an entry whose IccTagDataEntry.Signature is not IccTypeSignature.Curve or IccTypeSignature.ParametricCurve.","commonSituations":"Hand-constructing ICC LutAtoB/BToA entries with a mis-typed entry in the curves arrays; parsing a non-conformant ICC profile and re-serializing it; copying entries from one profile's tag table into another's Lut curves list.","solutions":["Inspect the curves arrays on the LutAtoB/LutBToA entry and remove or replace any entry whose Signature is not Curve or ParametricCurve","Convert curve data into a proper IccCurveTagDataEntry or IccParametricCurveTagDataEntry before assigning it to the entry","If the profile came from an external source, re-export it from a conformant tool so the Lut tag contains only curve entries","Wrap ICC writing in a try-catch on InvalidIccProfileException to surface a clear message about the offending entry"],"exampleFix":"// before\nvar entry = new IccLutAtoBTagDataEntry(..., curvesB: new IccTagDataEntry[] { someTextEntry });\n// after\nvar curveEntry = new IccCurveTagDataEntry(curveData);\nvar entry = new IccLutAtoBTagDataEntry(..., curvesB: new IccTagDataEntry[] { curveEntry });","handlingStrategy":"validation","validationCode":"bool valid = entry.CurvesM?.All(c => c.Signature is IccTypeSignature.Curve or IccTypeSignature.ParametricCurve) ?? true\n    && (entry.CurvesA?.All(c => c.Signature is IccTypeSignature.Curve or IccTypeSignature.ParametricCurve) ?? true)\n    && (entry.CurvesB?.All(c => c.Signature is IccTypeSignature.Curve or IccTypeSignature.ParametricCurve) ?? true);","typeGuard":"static bool IsCurveEntry(IccTagDataEntry e) => e.Signature is IccTypeSignature.Curve or IccTypeSignature.ParametricCurve;","tryCatchPattern":"try { writer.WriteTagDataEntry(lutEntry); } catch (InvalidIccProfileException ex) { log.Error(ex, \"Non-curve entry in Lut tag\"); throw; }","preventionTips":["Only build LutAtoB/BToA curves arrays from IccCurveTagDataEntry or IccParametricCurveTagDataEntry","Validate every entry's Signature before assignment","Round-trip test profiles you parse from external sources before re-serializing"],"tags":["icc","profile-writing","validation"],"backgroundTag":"invalid-argument-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"}