{"record":{"id":"3aa70f0920819498","repo":"SixLabors/ImageSharp","slug":"could-not-find-any-converter-for-jpegcolorspace-colorspace","errorCode":null,"errorMessage":"Could not find any converter for JpegColorSpace {colorSpace}!","messagePattern":"Could not find any converter for JpegColorSpace (.+?)!","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs","lineNumber":75,"sourceCode":"    /// <summary>\n    /// Gets the maximum value of a sample\n    /// </summary>\n    private float MaximumValue { get; }\n\n    /// <summary>\n    /// Gets the half of the maximum value of a sample\n    /// </summary>\n    private float HalfValue { get; }\n\n    /// <summary>\n    /// Returns the <see cref=\"JpegColorConverterBase\"/> corresponding to the given <see cref=\"JpegColorSpace\"/>\n    /// </summary>\n    /// <param name=\"colorSpace\">The color space.</param>\n    /// <param name=\"precision\">The precision in bits.</param>\n    /// <exception cref=\"InvalidImageContentException\">Invalid colorspace.</exception>\n    public static JpegColorConverterBase GetConverter(JpegColorSpace colorSpace, int precision)\n        => Array.Find(Converters, c => c.ColorSpace == colorSpace && c.Precision == precision)\n        ?? throw new InvalidImageContentException($\"Could not find any converter for JpegColorSpace {colorSpace}!\");\n\n    /// <summary>\n    /// Converts planar jpeg component values in <paramref name=\"values\"/> to RGB color space in-place.\n    /// </summary>\n    /// <param name=\"values\">The input/output as a stack-only <see cref=\"ComponentValues\"/> struct</param>\n    public abstract void ConvertToRgbInPlace(in ComponentValues values);\n\n    /// <summary>\n    /// Converts RGB lanes to jpeg component values.\n    /// </summary>\n    /// <param name=\"values\">Jpeg component values.</param>\n    /// <param name=\"rLane\">Red colors lane.</param>\n    /// <param name=\"gLane\">Green colors lane.</param>\n    /// <param name=\"bLane\">Blue colors lane.</param>\n    public abstract void ConvertFromRgb(in ComponentValues values, Span<float> rLane, Span<float> gLane, Span<float> bLane);\n\n    /// <summary>\n    /// Returns the <see cref=\"JpegColorConverterBase\"/>s for all supported color spaces and precisions.","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs#L57-L93","documentation":"JpegColorConverterBase.GetConverter looks up a color converter matching both the JPEG color space and the decoder precision; if none exists it throws InvalidImageContentException. The bitstream declares a color space/precision combination the library has no conversion implementation for.","triggerScenarios":"Decoding a JPEG whose frame indicates a JpegColorSpace (e.g. unusual YCCK/CMYK or Adobe-transform variants) combined with a precision (8 or 12 bit) for which no registered converter exists in JpegColorConverterBase.Converters.","commonSituations":"12-bit or 16-bit precision JPEGs from medical/scientific encoders; exotic CMYK JPEGs written by nonstandard encoders; corrupted SOF/marker data implying an invalid colorspace.","solutions":["Re-encode the JPEG to a standard 8-bit YCbCr or RGB colorspace with another tool before loading","Catch InvalidImageContentException and reject/convert the file at intake","Upgrade ImageSharp — new versions add converters for additional color spaces and precisions","Verify the file isn't corrupt: a malformed SOF can imply a bogus color space"],"exampleFix":"// before\nusing var image = Image.Load(oddJpegStream); // InvalidImageContentException\n// after\ntry { using var image = Image.Load(oddJpegStream); }\ncatch (InvalidImageContentException)\n{\n    // Convert with e.g. ImageMagick/skia to baseline YCbCr, then retry\n}","handlingStrategy":"try-catch","validationCode":"// Reject non-8-bit JPEGs before decoding\nif (IsTwelveBitJpeg(stream)) throw new UnsupportedFormatException(\"12-bit JPEG not supported.\");","typeGuard":null,"tryCatchPattern":"try { using var image = Image.Load(jpegStream); }\ncatch (InvalidImageContentException ex) when (ex.Message.Contains(\"converter\"))\n{\n    // colorspace/precision combination unsupported\n    return TranscodeWithExternalTool();\n}","preventionTips":["Normalize incoming JPEGs to baseline 8-bit at ingestion","Keep the ImageSharp package current — converter coverage grows over time","Log the JpegColorSpace from failures to detect recurring exotic inputs"],"tags":["dotnet","jpeg","color-space","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"}