From 1cbab324681f3b5c6ed1085fd45a75c0dd5ae6ae Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 8 Aug 2021 20:25:54 +0200 Subject: [PATCH] Throw not suported for YCbCr with subsampling --- src/ImageSharp/Formats/Tiff/README.md | 8 ++++---- src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/README.md b/src/ImageSharp/Formats/Tiff/README.md index 5b116b819a..3e4afe92e8 100644 --- a/src/ImageSharp/Formats/Tiff/README.md +++ b/src/ImageSharp/Formats/Tiff/README.md @@ -63,7 +63,7 @@ |PaletteColor | Y | Y | General implementation only | |TransparencyMask | | | | |Separated (TIFF Extension) | | | | -|YCbCr (TIFF Extension) | | | | +|YCbCr (TIFF Extension) | | Y | | |CieLab (TIFF Extension) | | | | |IccLab (TechNote 1) | | | | @@ -165,10 +165,10 @@ |JPEGQTables | | | | |JPEGDCTables | | | | |JPEGACTables | | | | -|YCbCrCoefficients | | | | -|YCbCrSubSampling | | | | +|YCbCrCoefficients | | Y | | +|YCbCrSubSampling | | Y | | |YCbCrPositioning | | | | -|ReferenceBlackWhite | | | | +|ReferenceBlackWhite | | Y | | |StripRowCounts | - | - | See RFC 2301 (File Format for Internet Fax). | |XMP | Y | Y | | |ImageID | | | | diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 1d1473dc43..86dc3c1df6 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -63,6 +63,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff TiffThrowHelper.ThrowNotSupported("ImageSharp only supports YCbCr images with equal luma and chroma samples."); } + if (ycbcrSubSampling != null && ycbcrSubSampling[0] != 1) + { + TiffThrowHelper.ThrowNotSupported("ImageSharp only supports YCbCr images without subsampling."); + } + if (exifProfile.GetValue(ExifTag.StripRowCounts)?.Value != null) { TiffThrowHelper.ThrowNotSupported("Variable-sized strips are not supported.");