diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index aca0758b82..f2f1470f94 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. -using System; using System.IO; using SixLabors.ImageSharp.Formats; @@ -414,7 +413,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff [Theory] [WithFile(GrayscaleUncompressed, PixelTypes.L8, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.PackBits)] - [WithFile(PaletteDeflateMultistrip, PixelTypes.L8, TiffPhotometricInterpretation.PaletteColor, TiffCompression.Lzw)] [WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb, TiffCompression.Deflate)] [WithFile(RgbUncompressed, PixelTypes.Rgb24, TiffPhotometricInterpretation.Rgb, TiffCompression.None)] [WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb, TiffCompression.None)] @@ -423,6 +421,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff where TPixel : unmanaged, IPixel => TestStripLength(provider, photometricInterpretation, compression); + [Theory] + [WithFile(PaletteDeflateMultistrip, PixelTypes.L8, TiffPhotometricInterpretation.PaletteColor, TiffCompression.Lzw)] + public void TiffEncoder_StripLength_WithPalette(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, TiffCompression compression) + where TPixel : unmanaged, IPixel => + TestStripLength(provider, photometricInterpretation, compression, false, 0.01f); + [Theory] [WithFile(Calliphora_BiColorUncompressed, PixelTypes.L8, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.CcittGroup3Fax)] public void TiffEncoder_StripLength_OutOfBounds(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, TiffCompression compression) @@ -430,7 +434,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff //// CcittGroup3Fax compressed data length can be larger than the original length. Assert.Throws(() => TestStripLength(provider, photometricInterpretation, compression)); - private static void TestStripLength(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation, TiffCompression compression) + private static void TestStripLength( + TestImageProvider provider, + TiffPhotometricInterpretation photometricInterpretation, + TiffCompression compression, + bool useExactComparer = true, + float compareTolerance = 0.01f) where TPixel : unmanaged, IPixel { // arrange @@ -476,20 +485,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff } } - // TODO: Ask Brian about this. It seems like some of the images used - // are saved in a lossy format which can lead to differences compared - // to the original file unless full precision is used. - if (photometricInterpretation == TiffPhotometricInterpretation.PaletteColor) - { - return; - } - // Compare with reference. TestTiffEncoderCore( provider, inputMeta.BitsPerPixel, photometricInterpretation, - inputCompression); + inputCompression, + useExactComparer: useExactComparer, + compareTolerance: compareTolerance); } private static void TestTiffEncoderCore(