From f23fdf27efce98aa3e0daccbe596b761f1297bb2 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 12 Oct 2022 13:33:58 +0200 Subject: [PATCH] Throw NotSupported exception with OldJpeg+Planar config --- src/ImageSharp/Formats/Tiff/README.md | 48 +++++++++---------- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 5 ++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/README.md b/src/ImageSharp/Formats/Tiff/README.md index d64e3339c..0ce467e3f 100644 --- a/src/ImageSharp/Formats/Tiff/README.md +++ b/src/ImageSharp/Formats/Tiff/README.md @@ -30,34 +30,34 @@ ### Compression Formats -| |Encoder|Decoder|Comments | -|---------------------------|:-----:|:-----:|--------------------------| -|None | Y | Y | | -|Ccitt1D | Y | Y | | -|PackBits | Y | Y | | -|CcittGroup3Fax | Y | Y | | -|CcittGroup4Fax | Y | Y | | +| |Encoder|Decoder|Comments | +|---------------------------|:-----:|:-----:|-----------------------------------| +|None | Y | Y | | +|Ccitt1D | Y | Y | | +|PackBits | Y | Y | | +|CcittGroup3Fax | Y | Y | | +|CcittGroup4Fax | Y | Y | | |Lzw | Y | Y | Based on ImageSharp GIF LZW implementation - this code could be modified to be (i) shared, or (ii) optimised for each case. | -|Old Jpeg | | Y | | -|Jpeg (Technote 2) | Y | Y | | -|Deflate (Technote 2) | Y | Y | Based on PNG Deflate. | -|Old Deflate (Technote 2) | | Y | | -|Webp | | Y | | +|Old Jpeg | | Y | Only with chunky configuration. | +|Jpeg (Technote 2) | Y | Y | | +|Deflate (Technote 2) | Y | Y | Based on PNG Deflate. | +|Old Deflate (Technote 2) | | Y | | +|Webp | | Y | | ### Photometric Interpretation Formats -| |Encoder|Decoder|Comments | -|---------------------------|:-----:|:-----:|--------------------------| -|WhiteIsZero | Y | Y | General + 1/4/8-bit optimised implementations | -|BlackIsZero | Y | Y | General + 1/4/8-bit optimised implementations | -|Rgb (Chunky) | Y | Y | General + Rgb888 optimised implementation | -|Rgb (Planar) | | Y | General implementation only | -|PaletteColor | Y | Y | General implementation only | -|TransparencyMask | | | | -|Separated (TIFF Extension) | | | | -|YCbCr (TIFF Extension) | | Y | | -|CieLab (TIFF Extension) | | Y | | -|IccLab (TechNote 1) | | | | +| |Encoder|Decoder|Comments | +|---------------------------|:-----:|:-----:|-------------------------------------------| +|WhiteIsZero | Y | Y | General + 1/4/8-bit optimised implementations. | +|BlackIsZero | Y | Y | General + 1/4/8-bit optimised implementations. | +|Rgb (Chunky) | Y | Y | General + Rgb888 optimised implementation.| +|Rgb (Planar) | | Y | General implementation only. | +|PaletteColor | Y | Y | General implementation only. | +|TransparencyMask | | | | +|Separated (TIFF Extension) | | | | +|YCbCr (TIFF Extension) | | Y | | +|CieLab (TIFF Extension) | | Y | | +|IccLab (TechNote 1) | | | | ### Baseline TIFF Tags diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index deaeb2deb..648b4a093 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -481,6 +481,11 @@ internal static class TiffDecoderOptionsParser TiffThrowHelper.ThrowNotSupported("Missing SOI marker offset for tiff with old jpeg compression"); } + if (options.PlanarConfiguration is TiffPlanarConfiguration.Planar) + { + TiffThrowHelper.ThrowNotSupported("Old Jpeg compression is not supported with planar configuration"); + } + options.CompressionType = TiffDecoderCompressionType.OldJpeg; if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr)