{"record":{"id":"806d4269cb3b23b5","repo":"SixLabors/ImageSharp","slug":"unknown-of-not-implemented-image-type-encountered","errorCode":null,"errorMessage":"Unknown of not implemented image type encountered.","messagePattern":"Unknown of not implemented image type encountered\\.","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs","lineNumber":137,"sourceCode":"                // Binary PBM format: 1 component per pixel, 8 pixels per byte.\n                this.colorType = PbmColorType.BlackAndWhite;\n                this.encoding = PbmEncoding.Binary;\n                break;\n            case '5':\n                // Binary PGM format: 1 components per pixel, in binary integers.\n                this.colorType = PbmColorType.Grayscale;\n                this.encoding = PbmEncoding.Binary;\n                break;\n            case '6':\n                // Binary PPM format: 3 components per pixel, in binary integers.\n                this.colorType = PbmColorType.Rgb;\n                this.encoding = PbmEncoding.Binary;\n                break;\n            case '7':\n            // PAM image: sequence of images.\n            // Not implemented yet\n            default:\n                throw new InvalidImageContentException(\"Unknown of not implemented image type encountered.\");\n        }\n\n        if (!stream.SkipWhitespaceAndComments() ||\n            !stream.ReadDecimal(out int width) ||\n            !stream.SkipWhitespaceAndComments() ||\n            !stream.ReadDecimal(out int height) ||\n            !stream.SkipWhitespaceAndComments())\n        {\n            ThrowPrematureEof();\n        }\n\n        if (this.colorType != PbmColorType.BlackAndWhite)\n        {\n            if (!stream.ReadDecimal(out this.maxPixelValue))\n            {\n                ThrowPrematureEof();\n            }\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs#L119-L155","documentation":"PbmDecoderCore.ProcessHeader throws InvalidImageContentException when the character after the 'P' magic byte does not correspond to a supported Netpbm subtype. Types '1'-'6' are handled (plain/binary PBM, PGM, PPM); '7' (PAM) is explicitly not implemented, and any other character hits the default case and is rejected.","triggerScenarios":"Decoding a PAM file ('P7' header) with the PBM decoder; decoding a corrupted or truncated Netpbm file whose type digit was overwritten; feeding a file whose second byte is not a valid subtype digit.","commonSituations":"Pipelines that lump all Netpbm formats together and encounter PAM (arbitrary-depth/alpha) files; hand-edited headers; partially overwritten or damaged files from storage or transfer.","solutions":["Check the second header byte: only '1'-'6' are supported; route 'P7' (PAM) files to a different decoder or convert them to PPM/PGM first.","Catch InvalidImageContentException around Load and report or skip unsupported Netpbm subtypes.","Pre-screen with Image.DetectFormat and reject PAM explicitly before attempting decode."],"exampleFix":"// before\nusing Image image = Image.Load(stream); // throws for PAM ('P7') files\n\n// after\nSpan<byte> magic = stackalloc byte[2];\nlong pos = stream.Position;\nstream.ReadExactly(magic);\nstream.Position = pos;\nif (magic[0] == (byte)'P' && magic[1] >= (byte)'1' && magic[1] <= (byte)'6')\n{\n    using Image image = Image.Load(stream);\n}","handlingStrategy":"validation","validationCode":"// Before decoding as PBM:\nSpan<byte> magic = stackalloc byte[2];\nlong pos = stream.Position;\nstream.ReadExactly(magic);\nstream.Position = pos;\nbool supported = magic[0] == (byte)'P' && magic[1] >= (byte)'1' && magic[1] <= (byte)'6';\nif (!supported)\n{\n    // route to a PAM-capable decoder or reject\n}","typeGuard":null,"tryCatchPattern":"// try\n{\n    using Image image = Image.Load(stream);\n}\ncatch (InvalidImageContentException ex)\n{\n    logger.LogWarning(ex, \"Unsupported Netpbm subtype (e.g. PAM), skipping\");\n}","preventionTips":["Screen Netpbm files for subtype digits 1-6; handle PAM ('P7') separately.","Convert PAM files to PPM/PGM before ImageSharp processing.","Use Image.DetectFormat to gate decoder selection."],"tags":["pbm","decoding","pam","unsupported"],"backgroundTag":"unsupported-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"}