{"record":{"id":"55ef54bf2b4ccbca","repo":"SixLabors/ImageSharp","slug":"images-with-componentcount-components-are-not-supported","errorCode":null,"errorMessage":"Images with {componentCount} components are not supported.","messagePattern":"Images with (.+?) components are not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs","lineNumber":30,"sourceCode":"    public static void ThrowBadMarker(string marker, int length) => throw new InvalidImageContentException($\"Marker {marker} has bad length {length}.\");\n\n    public static void ThrowNotEnoughBytesForMarker(byte marker) => throw new InvalidImageContentException($\"Input stream does not have enough bytes to parse declared contents of the {marker:X2} marker.\");\n\n    public static void ThrowBadQuantizationTableIndex(int index) => throw new InvalidImageContentException($\"Bad Quantization Table index {index}.\");\n\n    public static void ThrowBadQuantizationTablePrecision(int precision) => throw new InvalidImageContentException($\"Unknown Quantization Table precision {precision}.\");\n\n    public static void ThrowBadSampling() => throw new InvalidImageContentException(\"Bad sampling factor.\");\n\n    public static void ThrowBadSampling(int factor) => throw new InvalidImageContentException($\"Bad sampling factor: {factor}\");\n\n    public static void ThrowBadProgressiveScan(int ss, int se, int ah, int al) => throw new InvalidImageContentException($\"Invalid progressive parameters Ss={ss} Se={se} Ah={ah} Al={al}.\");\n\n    public static void ThrowInvalidImageDimensions(int width, int height) => throw new InvalidImageContentException($\"Invalid image dimensions: {width}x{height}.\");\n\n    public static void ThrowDimensionsTooLarge(int width, int height) => throw new ImageFormatException($\"Image is too large to encode at {width}x{height} for JPEG format.\");\n\n    public static void ThrowNotSupportedComponentCount(int componentCount) => throw new NotSupportedException($\"Images with {componentCount} components are not supported.\");\n\n    public static void ThrowNotSupportedColorSpace() => throw new NotSupportedException(\"Image color space could not be deduced.\");\n}\n","sourceCodeStart":12,"sourceCodeEnd":34,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs#L12-L34","documentation":"JpegThrowHelper.ThrowNotSupportedComponentCount(componentCount) throws NotSupportedException when a JPEG declares a number of color components the decoder does not handle (ImageSharp supports 1-component grayscale and 3-component YCbCr/RGB flows; exotic counts such as 4-component CMYK variants outside the supported paths or other counts are rejected). It is a decoder capability limit on non-standard or unsupported JPEGs.","triggerScenarios":"Decoding a JPEG whose SOF Nf component count is not in the supported set, e.g. unusual multi-channel scans produced by specialized cameras, prepress CMYK JPEGs with layouts the decoder rejects, or corrupt SOF segments with bogus Nf.","commonSituations":"Print/prepress workflows handling Adobe CMYK JPEGs; images from scanners or forensic tooling with non-standard component layouts; corrupt files with garbage in the SOF component-count byte.","solutions":["Convert the image to a standard RGB or grayscale JPEG with an external tool (e.g. ImageMagick, IrfanView) before decoding with ImageSharp.","Catch NotSupportedException around the decode call and route such files to a converter pipeline or alternative decoder.","Inspect the file's SOF component count up front and reject unsupported layouts early in your ingestion pipeline."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// try\n{\n    using Image image = Image.Load(stream);\n}\ncatch (NotSupportedException ex)\n{\n    logger.LogWarning(ex, \"Unsupported JPEG component count, converting externally\");\n}","preventionTips":["In print/prepress pipelines, convert CMYK JPEGs to standard RGB with an external tool before ImageSharp processing.","Route files rejected as unsupported to a fallback decoder instead of failing the job.","Document the supported JPEG flavor (1 or 3 components) in your ingestion contract."],"tags":["jpeg","decoding","component-count","unsupported"],"backgroundTag":"operation-not-supported","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"}