From cd68d14be5d458a1dc4a625eef4dc0a688add50b Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 7 Aug 2022 15:35:19 +0200 Subject: [PATCH] Make sure 1 Bit compression is only used with 1 bit pixel type. --- src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs index 27c4490737..16071001d5 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs @@ -417,6 +417,13 @@ private void SanitizeAndSetEncoderOptions(TiffBitsPerPixel? bitsPerPixel, int in return; case TiffPhotometricInterpretation.Rgb: + // Make sure 1 Bit compression is only used with 1 bit pixel type. + if (IsOneBitCompression(this.CompressionType)) + { + // Invalid compression / bits per pixel combination, fallback to no compression. + compression = DefaultCompression; + } + this.SetEncoderOptions(TiffBitsPerPixel.Bit24, photometricInterpretation, compression, predictor); return; }