{"record":{"id":"31eb6706b116467b","repo":"SixLabors/ImageSharp","slug":"image-color-space-could-not-be-deduced","errorCode":null,"errorMessage":"Image color space could not be deduced.","messagePattern":"Image color space could not be deduced\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs","lineNumber":32,"sourceCode":"    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":14,"sourceCodeEnd":34,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs#L14-L34","documentation":"JpegThrowHelper.ThrowNotSupportedColorSpace() throws NotSupportedException during decoding when ImageSharp cannot deduce the JPEG's color space from the component identifiers and Adobe APP14 transform metadata. Without a deducible color space the decoder cannot pick a valid conversion path, so it refuses the file.","triggerScenarios":"Decoding JPEGs with unrecognized component IDs (not Y/Cb/Cr, not R/G/B, not standard grayscale) and missing or contradictory Adobe APP14 markers; custom-encoded JPEGs with arbitrary component naming; corrupted marker segments.","commonSituations":"Files from niche or in-house encoders using custom component IDs; prepress pipelines where Adobe markers were stripped by a processor; files whose APP14 segment was lost through cropping/recompression tools.","solutions":["Re-save/convert the JPEG with a mainstream encoder (ImageSharp, libjpeg, ImageMagick) so it carries standard YCbCr or RGB component IDs before decoding.","Catch NotSupportedException around decode and fall back to an alternative decoder that guesses color spaces more leniently.","If you control the producing system, stop stripping the Adobe APP14 marker or emit standard 'R','G','B' / 'Y','Cb','Cr' component identifiers."],"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, \"JPEG color space could not be deduced; using fallback decoder\");\n}","preventionTips":["Normalize images from custom encoders by re-saving with a mainstream encoder before processing.","Do not strip Adobe APP14 metadata when recompressing JPEGs.","Keep a fallback decode path for non-standard JPEG variants."],"tags":["jpeg","decoding","color-space","unsupported"],"backgroundTag":"unsupported-operation","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"}