Skip to content

Commit d33b364

Browse files
authored
Merge pull request #2201 from SixLabors/bp/issue2179
Tiff: Make sure 1 Bit compression is only used with 1 bit pixel type
2 parents ffac532 + cd68d14 commit d33b364

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ private void SanitizeAndSetEncoderOptions(TiffBitsPerPixel? bitsPerPixel, int in
417417
return;
418418

419419
case TiffPhotometricInterpretation.Rgb:
420+
// Make sure 1 Bit compression is only used with 1 bit pixel type.
421+
if (IsOneBitCompression(this.CompressionType))
422+
{
423+
// Invalid compression / bits per pixel combination, fallback to no compression.
424+
compression = DefaultCompression;
425+
}
426+
420427
this.SetEncoderOptions(TiffBitsPerPixel.Bit24, photometricInterpretation, compression, predictor);
421428
return;
422429
}

0 commit comments

Comments
 (0)