Skip to content

Commit 5c60126

Browse files
committed
Add check, if YcbcrSubSampling has a value
1 parent 978aff8 commit 5c60126

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -633,21 +633,22 @@ private static void ParseCompression(this TiffDecoderCore options, TiffCompressi
633633
case TiffCompression.Jpeg:
634634
{
635635
options.CompressionType = TiffDecoderCompressionType.Jpeg;
636-
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr && options.JpegTables is null)
637-
{
638-
// Note: Setting PhotometricInterpretation and color type to RGB here, since the jpeg decoder will handle the conversion of the pixel data.
639-
options.PhotometricInterpretation = TiffPhotometricInterpretation.Rgb;
640-
options.ColorType = TiffColorType.Rgb;
641-
}
642636

643637
// Some tiff encoder set this to values different from [1, 1]. The jpeg decoder already handles this,
644638
// so we set this always to [1, 1], see: https://github.com/SixLabors/ImageSharp/issues/2679
645-
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr)
639+
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr && options.YcbcrSubSampling != null)
646640
{
647641
options.YcbcrSubSampling[0] = 1;
648642
options.YcbcrSubSampling[1] = 1;
649643
}
650644

645+
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr && options.JpegTables is null)
646+
{
647+
// Note: Setting PhotometricInterpretation and color type to RGB here, since the jpeg decoder will handle the conversion of the pixel data.
648+
options.PhotometricInterpretation = TiffPhotometricInterpretation.Rgb;
649+
options.ColorType = TiffColorType.Rgb;
650+
}
651+
651652
break;
652653
}
653654

0 commit comments

Comments
 (0)