SixLabors/ImageSharp · error · NotSupportedException

Not supported encoder compression method

Error message

Not supported encoder compression method: {compressionType}

What it means

Thrown when encoding an image to EXR with a compression method the encoder does not support. Unlike the decoder twin, this is triggered by user configuration: the requested ExrCompression is not implemented for writing. It is a NotSupportedException surfaced from the encoder path.

Solutions

  1. Use a supported ExrCompression value (None, RLE, Zip, Piz) in the ExrEncoder options
  2. Remove the explicit Compression setting to use the default
  3. Check the enum value against the ImageSharp version's ExrCompression definition

Example fix

// before
var encoder = new ExrEncoder { Compression = (ExrCompression)42 }; // throws
// after
var encoder = new ExrEncoder { Compression = ExrCompression.Zip };
Defensive patterns

Strategy: validation

Validate before calling

// Only pass known-supported compressions to the encoder
bool isSupported(ExrCompression c) => c is ExrCompression.None or ExrCompression.Rle or ExrCompression.Zip or ExrCompression.Piz;
if (!isSupported(encoder.Compression)) encoder.Compression = ExrCompression.Zip;

Try / catch

try { image.EncodeAsExr(stream, encoder); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Not supported encoder compression")) { encoder.Compression = ExrCompression.None; image.EncodeAsExr(stream, encoder); }

Prevention

When it happens

Trigger: Setting ExrEncoder.Compression to a value not supported by the encoder (e.g. passing an enum value cast outside the valid range or a method not implemented for writing) and calling EncodeAsExr/SaveAsync with that options object.

Common situations: Configuration mistakes where an enum from a different API is cast into ExrCompression, or copying encoder options across library versions where valid values changed.

Related errors


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

Appendix: source

Thrown at src/ImageSharp/Formats/Exr/ExrThrowHelper.cs:32

    public static Exception NotSupportedDecompressor(string compressionType) => throw new NotSupportedException($"Not supported decoder compression method: {compressionType}");

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

    [DoesNotReturn]
    public static void ThrowNotSupportedVersion() => throw new NotSupportedException("Unsupported EXR version");

    [DoesNotReturn]
    public static void ThrowNotSupported(string msg) => throw new NotSupportedException(msg);

    [DoesNotReturn]
    public static void ThrowInvalidImageHeader() => throw new InvalidImageContentException("Invalid EXR image header");

    [DoesNotReturn]
    public static void ThrowInvalidImageHeader(string msg) => throw new InvalidImageContentException(msg);

    [DoesNotReturn]
    public static Exception NotSupportedCompressor(string compressionType) => throw new NotSupportedException($"Not supported encoder compression method: {compressionType}");
}

View on GitHub (pinned to 59ce6af6fc)