{"record":{"id":"fe7798c232c6e9d3","repo":"SixLabors/ImageSharp","slug":"errormessage","errorCode":null,"errorMessage":"{errorMessage}","messagePattern":"\\{errorMessage\\}","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs","lineNumber":8,"sourceCode":"// Copyright (c) Six Labors.\n// Licensed under the Six Labors Split License.\n\nnamespace SixLabors.ImageSharp.Formats.Jpeg;\n\ninternal static class JpegThrowHelper\n{\n    public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage);\n\n    public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);\n\n    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}.\");","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs#L1-L26","documentation":"JpegThrowHelper.ThrowNotSupportedException wraps NotSupportedException for features the JPEG codec explicitly does not support (e.g. 12-bit or arithmetic-coded baselines, certain marker combinations). It is an internal helper so throw sites stay JIT-friendly (no string interpolation on the hot path).","triggerScenarios":"Decoding a JPEG stream whose features are outside the codec's supported subset — most commonly 12-bit quantization/precision or arithmetic entropy coding — via Image.Load/LoadAsync on a JpegDecoder.","commonSituations":"Processing images produced by medical/scientific (DICOM-adjacent) or high-bit-depth cameras exporting 12-bit JPEGs; legacy encoders using arithmetic coding; pipelines migrating from other decoders (libjpeg-turbo) that accepted these files.","solutions":["Re-encode the source image to standard 8-bit baseline or progressive JPEG using an external tool (e.g. ImageMagick, IrfanView) before loading.","Upgrade ImageSharp — support for more JPEG features is added over time; check the release notes for 12-bit/arithmetic support.","Catch NotSupportedException and route the file to a fallback decoder that supports the feature."],"exampleFix":"// before\nusing var image = Image.Load(stream); // throws on unsupported JPEG\n// after\ntry\n{\n    using var image = Image.Load(stream);\n}\ncatch (NotSupportedException)\n{\n    // fall back to external decoder or reject the file\n}","handlingStrategy":"try-catch","validationCode":"// No pre-check API; sniff capability only by reading SOF precision from the file header bytes.","typeGuard":null,"tryCatchPattern":"try\n{\n    using var image = Image.Load(stream);\n}\ncatch (NotSupportedException ex)\n{\n    // route to external decoder or reject: unsupported JPEG feature\n}","preventionTips":["Detect 12-bit/arithmetic-coded JPEGs upstream (e.g. ImageMagick 'identify -verbose') and convert them beforehand.","Pin and review ImageSharp release notes for newly supported JPEG features before upgrading producers.","Keep a fallback decoder configured for images from medical/scientific sources."],"tags":["jpeg","decoder","not-supported","format"],"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"}