Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private void DecodeImageWithTiles<TPixel>(ExifProfile tags, ImageFrame<TPixel> f
ArgumentNullException.ThrowIfNull(valueWidth);
}

if (!tags.TryGetValue(ExifTag.TileWidth, out IExifValue<Number> valueLength))
if (!tags.TryGetValue(ExifTag.TileLength, out IExifValue<Number> valueLength))
{
ArgumentNullException.ThrowIfNull(valueLength);
}
Expand Down
48 changes: 13 additions & 35 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ public void TiffDecoder_CanDecode_12Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[Theory]
[WithFile(Rgba3BitAssociatedAlpha, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_12Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.264F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.264F);

[Theory]
[WithFile(Flower14BitGray, PixelTypes.Rgba32)]
Expand Down Expand Up @@ -249,11 +245,7 @@ public void TiffDecoder_CanDecode_20Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[WithFile(Rgba5BitAssociatedAlpha, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_20Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)

where TPixel : unmanaged, IPixel<TPixel>
{

TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.376F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.376F);

[Theory]
[WithFile(FlowerRgb888Contiguous, PixelTypes.Rgba32)]
Expand All @@ -268,11 +260,7 @@ public void TiffDecoder_CanDecode_24Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[Theory]
[WithFile(Rgba6BitAssociatedAlpha, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_24Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.405F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.405F);

[Theory]
[WithFile(Flower24BitGray, PixelTypes.Rgba32)]
Expand Down Expand Up @@ -362,12 +350,8 @@ public void TiffDecoder_CanDecode_32Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[Theory]
[WithFile(Rgba8BitAssociatedAlpha, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_32Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

// Note: Using tolerant comparer here, because there is a small difference to the reference decoder probably due to floating point rounding issues.
TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.004F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.004F);

[Theory]
[WithFile(Flower32BitGrayPredictorBigEndian, PixelTypes.Rgba32)]
Expand Down Expand Up @@ -395,11 +379,7 @@ public void TiffDecoder_CanDecode_40Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[WithFile(Rgba10BitAssociatedAlphaBigEndian, PixelTypes.Rgba32)]
[WithFile(Rgba10BitAssociatedAlphaLittleEndian, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_40Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.247F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.247F);

[Theory]
[WithFile(FlowerRgb141414Contiguous, PixelTypes.Rgba32)]
Expand All @@ -426,11 +406,7 @@ public void TiffDecoder_CanDecode_48Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[WithFile(Rgba12BitAssociatedAlphaBigEndian, PixelTypes.Rgba32)]
[WithFile(Rgba12BitAssociatedAlphaLittleEndian, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_48Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.118F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.118F);

[Theory]
[WithFile(FlowerRgb161616PredictorBigEndian, PixelTypes.Rgba32)]
Expand All @@ -448,11 +424,7 @@ public void TiffDecoder_CanDecode_56Bit_WithUnassociatedAlpha<TPixel>(TestImageP
[WithFile(Rgba14BitAssociatedAlphaBigEndian, PixelTypes.Rgba32)]
[WithFile(Rgba14BitAssociatedAlphaLittleEndian, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_56Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.075F);
}
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.075F);

[Theory]
[WithFile(FlowerRgb242424Contiguous, PixelTypes.Rgba32)]
Expand Down Expand Up @@ -686,6 +658,12 @@ public void TiffDecoder_ThrowsException_WithTooManyDirectories<TPixel>(TestImage
public void TiffDecoder_CanDecode_Fax4CompressedWithStrips<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider);

// https://github.com/SixLabors/ImageSharp/issues/2435
[Theory]
[WithFile(Issues2435, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_TiledWithNonEqualWidthAndHeight<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider);

[Theory]
[WithFileCollection(nameof(MultiframeTestImages), PixelTypes.Rgba32)]
public void DecodeMultiframe<TPixel>(TestImageProvider<TPixel> provider)
Expand Down
1 change: 1 addition & 0 deletions tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ public static class Tiff
public const string Issues2123 = "Tiff/Issues/Issue2123.tiff";
public const string Issues2149 = "Tiff/Issues/Group4CompressionWithStrips.tiff";
public const string Issues2255 = "Tiff/Issues/Issue2255.png";
public const string Issues2435 = "Tiff/Issues/Issue2435.tiff";

public const string SmallRgbDeflate = "Tiff/rgb_small_deflate.tiff";
public const string SmallRgbLzw = "Tiff/rgb_small_lzw.tiff";
Expand Down
3 changes: 3 additions & 0 deletions tests/Images/Input/Tiff/Issues/Issue2435.tiff
Git LFS file not shown