Browse Source
Merge branch 'main' into js/rework-2589
pull/2786/head
James Jackson-South
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
32 additions and
1 deletions
-
src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs
-
tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_JpegCompressedWithIssue2679_Issue2679.png
-
tests/Images/Input/Tiff/Issues/Issue2679.tiff
|
|
|
@ -572,7 +572,6 @@ internal static class TiffDecoderOptionsParser |
|
|
|
} |
|
|
|
|
|
|
|
options.CompressionType = TiffDecoderCompressionType.OldJpeg; |
|
|
|
|
|
|
|
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr) |
|
|
|
{ |
|
|
|
// Note: Setting PhotometricInterpretation and color type to RGB here, since the jpeg decoder will handle the conversion of the pixel data.
|
|
|
|
@ -585,6 +584,14 @@ internal static class TiffDecoderOptionsParser |
|
|
|
case TiffCompression.Jpeg: |
|
|
|
options.CompressionType = TiffDecoderCompressionType.Jpeg; |
|
|
|
|
|
|
|
// Some tiff encoder set this to values different from [1, 1]. The jpeg decoder already handles this,
|
|
|
|
// so we set this always to [1, 1], see: https://github.com/SixLabors/ImageSharp/issues/2679
|
|
|
|
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr && options.YcbcrSubSampling != null) |
|
|
|
{ |
|
|
|
options.YcbcrSubSampling[0] = 1; |
|
|
|
options.YcbcrSubSampling[1] = 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr && options.JpegTables is null) |
|
|
|
{ |
|
|
|
// Note: Setting PhotometricInterpretation and color type to RGB here, since the jpeg decoder will handle the conversion of the pixel data.
|
|
|
|
|
|
|
|
@ -671,6 +671,23 @@ public class TiffDecoderTests : TiffDecoderBaseTester |
|
|
|
public void TiffDecoder_CanDecode_BiColorWithMissingBitsPerSample<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider); |
|
|
|
|
|
|
|
// https://github.com/SixLabors/ImageSharp/issues/2679
|
|
|
|
[Theory] |
|
|
|
[WithFile(Issues2679, PixelTypes.Rgba32)] |
|
|
|
public void TiffDecoder_CanDecode_JpegCompressedWithIssue2679<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using Image<TPixel> image = provider.GetImage(TiffDecoder.Instance); |
|
|
|
|
|
|
|
// The image is handcrafted to simulate issue 2679. ImageMagick will throw an expection here and wont decode,
|
|
|
|
// so we compare to rererence output instead.
|
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToReferenceOutput( |
|
|
|
ImageComparer.Exact, |
|
|
|
provider, |
|
|
|
appendPixelTypeToFileName: false); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(JpegCompressedGray0000539558, PixelTypes.Rgba32)] |
|
|
|
public void TiffDecoder_ThrowsException_WithCircular_IFD_Offsets<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
|
|
|
|
@ -1047,6 +1047,7 @@ public static class TestImages |
|
|
|
public const string Issues2255 = "Tiff/Issues/Issue2255.png"; |
|
|
|
public const string Issues2435 = "Tiff/Issues/Issue2435.tiff"; |
|
|
|
public const string Issues2587 = "Tiff/Issues/Issue2587.tiff"; |
|
|
|
public const string Issues2679 = "Tiff/Issues/Issue2679.tiff"; |
|
|
|
public const string JpegCompressedGray0000539558 = "Tiff/Issues/JpegCompressedGray-0000539558.tiff"; |
|
|
|
public const string Tiled0000023664 = "Tiff/Issues/tiled-0000023664.tiff"; |
|
|
|
|
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:6cd36c7e07a08e22cceecd28a056c80e5553a8c092bfc091e902d13bd5c46f4d |
|
|
|
size 120054 |
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:feb938396b9d5b4c258244197ba382937a52c93f72cc91081c7e6810e4a3b94c |
|
|
|
size 6136 |