{"record":{"id":"578c21995ebd74eb","repo":"SixLabors/ImageSharp","slug":"not-supported-encoder-compression-method-compressiontype-578c21","errorCode":null,"errorMessage":"Not supported encoder compression method: {compressionType}","messagePattern":"Not supported encoder compression method: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Tiff/TiffThrowHelper.cs","lineNumber":20,"sourceCode":"// Licensed under the Six Labors Split License.\n\nusing System.Diagnostics.CodeAnalysis;\n\nnamespace SixLabors.ImageSharp.Formats.Tiff;\n\ninternal static class TiffThrowHelper\n{\n    [DoesNotReturn]\n    public static Exception ThrowImageFormatException(string errorMessage) => throw new ImageFormatException(errorMessage);\n\n    [DoesNotReturn]\n    public static Exception ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);\n\n    [DoesNotReturn]\n    public static Exception NotSupportedDecompressor(string compressionType) => throw new NotSupportedException($\"Not supported decoder compression method: {compressionType}\");\n\n    [DoesNotReturn]\n    public static Exception NotSupportedCompressor(string compressionType) => throw new NotSupportedException($\"Not supported encoder compression method: {compressionType}\");\n\n    [DoesNotReturn]\n    public static Exception InvalidColorType(string colorType) => throw new NotSupportedException($\"Invalid color type: {colorType}\");\n\n    [DoesNotReturn]\n    public static Exception ThrowInvalidHeader() => throw new ImageFormatException(\"Invalid TIFF file header.\");\n\n    [DoesNotReturn]\n    public static void ThrowNotSupported(string message) => throw new NotSupportedException(message);\n\n    [DoesNotReturn]\n    public static void ThrowArgumentException(string message) => throw new ArgumentException(message);\n}\n","sourceCodeStart":2,"sourceCodeEnd":34,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Tiff/TiffThrowHelper.cs#L2-L34","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar encoder = new TiffEncoder { Compression = TiffCompression.OldJpeg };\nimage.SaveAsTiff(\"out.tiff\", encoder);\n// after\nvar encoder = new TiffEncoder { Compression = TiffCompression.Deflate };\nimage.SaveAsTiff(\"out.tiff\", encoder);","handlingStrategy":"validation","validationCode":"var supported = new[] { TiffCompression.None, TiffCompression.Lzw, TiffCompression.Deflate, TiffCompression.PackBits };\nif (!supported.Contains(encoder.Compression)) encoder = new TiffEncoder { Compression = TiffCompression.Deflate };","typeGuard":"static bool IsSupportedTiffEncoderCompression(TiffCompression c) =>\n    c is TiffCompression.None or TiffCompression.Lzw or TiffCompression.Deflate or TiffCompression.PackBits;","tryCatchPattern":"try { image.SaveAsTiff(path, encoder); }\ncatch (NotSupportedException ex) { log.Error(ex, \"Unsupported TIFF encoder compression {C}\", encoder.Compression); /* retry with Deflate */ }","preventionTips":["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"],"tags":["tiff","encoder","notsupported","compression"],"backgroundTag":"unsupported-enum-value","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"}