{"record":{"id":"720f8e3c0efdf448","repo":"SixLabors/ImageSharp","slug":"invalid-clut-size-of-size","errorCode":null,"errorMessage":"Invalid CLUT size of {size}","messagePattern":"Invalid CLUT size of (.+?)","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs","lineNumber":60,"sourceCode":"    {\n        // Grid-points are always 16 bytes long but only 0-inChCount are used.\n        byte[] gridPointCount = new byte[inChannelCount];\n        Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount);\n\n        if (!isFloat)\n        {\n            byte size = this.data[this.AddIndex(4)];   // First byte is info, last 3 bytes are reserved\n            if (size == 1)\n            {\n                return this.ReadClut8(inChannelCount, outChannelCount, gridPointCount);\n            }\n\n            if (size == 2)\n            {\n                return this.ReadClut16(inChannelCount, outChannelCount, gridPointCount);\n            }\n\n            throw new InvalidIccProfileException($\"Invalid CLUT size of {size}\");\n        }\n\n        return this.ReadClutF32(inChannelCount, outChannelCount, gridPointCount);\n    }\n\n    /// <summary>\n    /// Reads an 8 bit CLUT.\n    /// </summary>\n    /// <param name=\"inChannelCount\">Input channel count.</param>\n    /// <param name=\"outChannelCount\">Output channel count.</param>\n    /// <param name=\"gridPointCount\">Grid point count for each CLUT channel.</param>\n    /// <returns>The read CLUT8.</returns>\n    public IccClut ReadClut8(int inChannelCount, int outChannelCount, byte[] gridPointCount)\n    {\n        int length = this.GetClutLength(inChannelCount, outChannelCount, gridPointCount, 1);\n\n        const float Max = byte.MaxValue;\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs#L42-L78","documentation":"The CLUT (color lookup table) header inside a lut16/lutAtoB/lutBToA tag declares a data size value that is neither 1 (8-bit), 2 (16-bit), nor 4 (32-bit float). The reader only knows how to decode those three representations, so any other declared precision is treated as a corrupt or unsupported profile.","triggerScenarios":"Reading an ICC profile whose lut16Type/lutAToBType/lutBToAType tag contains a CLUT with a declared entry-byte-size value other than 1, 2, or 4; corrupted bytes in the CLUT header can also produce an arbitrary value.","commonSituations":"Loading ICC profiles produced by buggy or non-conformant profiling software; profiles with flipped/shifted bits from bad transfers; attempting to read a profile variant the library does not support.","solutions":["Regenerate the profile so the CLUT uses a standard 8-bit, 16-bit, or 32-bit float representation.","Validate the profile with an ICC conformance tool before loading to pinpoint the malformed tag.","Check the file for corruption (compare checksum, re-download or re-export).","If support for a nonstandard size is genuinely needed, open an issue upstream - the library only handles sizes 1/2/4."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { profile = IccReader.Read(stream); }\ncatch (InvalidIccProfileException ex) when (ex.Message.Contains(\"CLUT\"))\n{\n    profile = IccProfile.Default;\n}","preventionTips":["Only load profiles from trusted, validated sources","Check file integrity (size, checksum) before parsing","Prefer modern 32-bit float or 16-bit CLUT profiles","Handle corrupt third-party profiles at a higher level with graceful degradation"],"tags":["icc","clut","profile-validation"],"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"}