SixLabors/ImageSharp · error · InvalidImageContentException

Invalid progressive parameters Ss=

Error message

Invalid progressive parameters Ss={ss} Se={se} Ah={ah} Al={al}.

What it means

JpegThrowHelper.ThrowBadProgressiveScan(ss, se, ah, al) throws InvalidImageContentException when a progressive JPEG's SOS scan header declares spectral selection (Ss/Se) or successive-approximation (Ah/Al) parameters outside the ranges allowed by the JPEG spec. It indicates the stream violates progressive-scan constraints and cannot be decoded safely.

Solutions

  1. Treat the file as malformed: discard it or re-obtain it; the stream's scan headers are invalid.
  2. Wrap decode calls in try-catch for InvalidImageContentException and fall back to another decoder or a placeholder image.
  3. Re-encode the source with a conformant tool to produce valid progressive (or baseline) scans before processing.
Defensive patterns

Strategy: try-catch

Try / catch

// try
{
    using Image image = Image.Load(stream);
}
catch (InvalidImageContentException ex)
{
    logger.LogWarning(ex, "Invalid progressive scan parameters, skipping file");
}

Prevention

When it happens

Trigger: Decoding a progressive JPEG whose scan header has Ss > Se, Se > 63, Ss = 0 with Se != 0 for AC scans, invalid DC scan ranges, or Ah/Al not in 0-15; feeding a corrupted or fuzzed progressive JPEG to Image.Load/Image.Identify.

Common situations: User uploads of damaged progressive JPEGs; thumbnails extracted from truncated progressive files; files produced by broken encoders or tools that rewrite only part of a progressive stream.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13). Data as JSON: /api/errors/f078dd7693da4cf7. Report an issue: GitHub.

Appendix: source

Thrown at src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs:24

internal static class JpegThrowHelper
{
    public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage);

    public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);

    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)