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
- Use a supported ExrCompression value (None, RLE, Zip, Piz) in the ExrEncoder options
- Remove the explicit Compression setting to use the default
- 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
- Never cast raw ints into ExrCompression
- Only assign ExrCompression enum members from the same ImageSharp version
- Keep encoder options in strongly-typed config, not user-supplied ints
- Default to None/Zip unless a specific compression is required
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
- Not supported decoder compression method
- Not supported encoder compression method
- Invalid window size for ZLIB header: cinfo=
- Bad method for ZLIB header: cmf=
- Image is too large to encode in EXR format.
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)