SixLabors/ImageSharp · error · NotSupportedException
Images with components are not supported.
Error message
Images with {componentCount} components are not supported. What it means
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.
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.
Defensive patterns
Strategy: try-catch
Try / catch
// try
{
using Image image = Image.Load(stream);
}
catch (NotSupportedException ex)
{
logger.LogWarning(ex, "Unsupported JPEG component count, converting externally");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Image color space could not be deduced.
- Could not find any converter for JpegColorSpace
- Bad sampling factor
- Invalid progressive parameters Ss=
- Invalid image dimensions
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/55ef54bf2b4ccbca.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs:30
public static void ThrowBadMarker(string marker, int length) => throw new InvalidImageContentException($"Marker {marker} has bad length {length}.");
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.");
public static void ThrowBadQuantizationTableIndex(int index) => throw new InvalidImageContentException($"Bad Quantization Table index {index}.");
public static void ThrowBadQuantizationTablePrecision(int precision) => throw new InvalidImageContentException($"Unknown Quantization Table precision {precision}.");
public static void ThrowBadSampling() => throw new InvalidImageContentException("Bad sampling factor.");
public static void ThrowBadSampling(int factor) => throw new InvalidImageContentException($"Bad sampling factor: {factor}");
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}.");
public static void ThrowInvalidImageDimensions(int width, int height) => throw new InvalidImageContentException($"Invalid image dimensions: {width}x{height}.");
public static void ThrowDimensionsTooLarge(int width, int height) => throw new ImageFormatException($"Image is too large to encode at {width}x{height} for JPEG format.");
public static void ThrowNotSupportedComponentCount(int componentCount) => throw new NotSupportedException($"Images with {componentCount} components are not supported.");
public static void ThrowNotSupportedColorSpace() => throw new NotSupportedException("Image color space could not be deduced.");
}
View on GitHub (pinned to 59ce6af6fc)