SixLabors/ImageSharp · error · NotSupportedException
Not supported encoder compression method
Error message
Not supported encoder compression method: {compressionType} What it means
TiffThrowHelper.NotSupportedCompressor throws NotSupportedException when the encoder is asked to write a TIFF frame using a compression method the library has no encoder for. TIFF compression is chosen per-frame from the Compression enum; many decoder-supported compressions (e.g. old-style JPEG) have no corresponding encoder. This is an intentional capability boundary, not a data corruption bug.
Solutions
- Set TiffEncoder.Compression to a supported encoder value such as None, Lzw, Deflate, PackBits, or CcittGroup3/4 (CCITT only for bilevel).
- If preserving the source compression, read TiffFrameMetadata.Compression and fall back to Deflate when no encoder exists for it.
- Remove explicit compression settings so the encoder default (Deflate) is used.
- Check the ImageSharp changelog/releases for added encoder compression support and upgrade if the needed method was added.
Example fix
// before
var encoder = new TiffEncoder { Compression = TiffCompression.OldJpeg };
image.SaveAsTiff("out.tiff", encoder);
// after
var encoder = new TiffEncoder { Compression = TiffCompression.Deflate };
image.SaveAsTiff("out.tiff", encoder); Defensive patterns
Strategy: validation
Validate before calling
var supported = new[] { TiffCompression.None, TiffCompression.Lzw, TiffCompression.Deflate, TiffCompression.PackBits };
if (!supported.Contains(encoder.Compression)) encoder = new TiffEncoder { Compression = TiffCompression.Deflate }; Type guard
static bool IsSupportedTiffEncoderCompression(TiffCompression c) =>
c is TiffCompression.None or TiffCompression.Lzw or TiffCompression.Deflate or TiffCompression.PackBits; Try / catch
try { image.SaveAsTiff(path, encoder); }
catch (NotSupportedException ex) { log.Error(ex, "Unsupported TIFF encoder compression {C}", encoder.Compression); /* retry with Deflate */ } Prevention
- Only set Compression from the known supported encoder set
- When round-tripping, map decoder compressions to encoder-supported ones
- Default to Deflate unless a specific requirement exists
When it happens
Trigger: Calling Image.Save/SaveAsTiff (directly or via ImageEncoder) on an image whose TiffFrameMetadata or encoder options specify a TiffCompression value without an implemented encoder path, e.g. setting Encoder.Compression = TiffCompression.OldJpeg.
Common situations: Configuring TiffEncoder with a compression copied from a source TIFF decoded elsewhere; round-tripping files that use legacy compressions; switching encoder options after migrating code between ImageSharp versions where encoder compression support expanded.
Related errors
- Not supported encoder compression method
- Not supported decoder compression method
- Invalid color type
- Invalid window size for ZLIB header: cinfo=
- Bad method for ZLIB header: cmf=
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/578c21995ebd74eb.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/Formats/Tiff/TiffThrowHelper.cs:20
// Licensed under the Six Labors Split License.
using System.Diagnostics.CodeAnalysis;
namespace SixLabors.ImageSharp.Formats.Tiff;
internal static class TiffThrowHelper
{
[DoesNotReturn]
public static Exception ThrowImageFormatException(string errorMessage) => throw new ImageFormatException(errorMessage);
[DoesNotReturn]
public static Exception ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);
[DoesNotReturn]
public static Exception NotSupportedDecompressor(string compressionType) => throw new NotSupportedException($"Not supported decoder compression method: {compressionType}");
[DoesNotReturn]
public static Exception NotSupportedCompressor(string compressionType) => throw new NotSupportedException($"Not supported encoder compression method: {compressionType}");
[DoesNotReturn]
public static Exception InvalidColorType(string colorType) => throw new NotSupportedException($"Invalid color type: {colorType}");
[DoesNotReturn]
public static Exception ThrowInvalidHeader() => throw new ImageFormatException("Invalid TIFF file header.");
[DoesNotReturn]
public static void ThrowNotSupported(string message) => throw new NotSupportedException(message);
[DoesNotReturn]
public static void ThrowArgumentException(string message) => throw new ArgumentException(message);
}
View on GitHub (pinned to 59ce6af6fc)