Browse Source

Add compression to the tiff metadata

pull/1570/head
Brian Popow 5 years ago
parent
commit
cbb69113cd
  1. 63
      src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
  2. 16
      src/ImageSharp/Formats/Tiff/TiffDecoderHelpers.cs
  3. 5
      src/ImageSharp/Formats/Tiff/TiffMetadata.cs
  4. 4
      tests/ImageSharp.Tests/Formats/Bmp/BmpMetadataTests.cs
  5. 48
      tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs
  6. 86
      tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs
  7. 3
      tests/ImageSharp.Tests/TestImages.cs
  8. 3
      tests/Images/Input/Tiff/Calliphora_ccitt_fax4.tiff
  9. 3
      tests/Images/Input/Tiff/b0350_lsb_to_msb.tiff

63
src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs

@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
public TiffColorType ColorType { get; set; }
/// <summary>
/// Gets or sets the compression implementation to use when decoding the image.
/// Gets or sets the compression used, when the image was encoded.
/// </summary>
public TiffDecoderCompressionType CompressionType { get; set; }
@ -122,8 +122,7 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
}
this.metadata = framesMetadata.CreateMetadata(this.ignoreMetadata, tiffStream.ByteOrder);
this.tiffMetaData = this.metadata.GetTiffMetadata();
this.SetBitsPerPixel(framesMetadata);
this.SetTiffFormatMetaData(framesMetadata, tiffStream.ByteOrder);
// todo: tiff frames can have different sizes
{
@ -143,30 +142,6 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
return image;
}
private void SetBitsPerPixel(List<TiffFrameMetadata> framesMetadata)
{
TiffFrameMetadata firstMetaData = framesMetadata.First();
ushort[] bitsPerSample = firstMetaData.BitsPerSample;
var bitsPerPixel = 0;
foreach (var bps in bitsPerSample)
{
bitsPerPixel += bps;
}
if (bitsPerPixel == 24)
{
this.tiffMetaData.BitsPerPixel = TiffBitsPerPixel.Pixel24;
}
else if (bitsPerPixel == 8)
{
this.tiffMetaData.BitsPerPixel = TiffBitsPerPixel.Pixel8;
}
else if (bitsPerPixel == 1)
{
this.tiffMetaData.BitsPerPixel = TiffBitsPerPixel.Pixel1;
}
}
/// <inheritdoc/>
public IImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken)
{
@ -182,7 +157,7 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
framesMetadata.Add(new TiffFrameMetadata() { Tags = ifd });
}
ImageMetadata metadata = framesMetadata.CreateMetadata(this.ignoreMetadata, tiffStream.ByteOrder);
this.SetTiffFormatMetaData(framesMetadata, tiffStream.ByteOrder);
TiffFrameMetadata root = framesMetadata.First();
int bitsPerPixel = 0;
@ -194,6 +169,38 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
return new ImageInfo(new PixelTypeInfo(bitsPerPixel), (int)root.Width, (int)root.Height, metadata);
}
private void SetTiffFormatMetaData(List<TiffFrameMetadata> framesMetadata, TiffByteOrder byteOrder)
{
this.metadata = framesMetadata.CreateMetadata(this.ignoreMetadata, byteOrder);
this.tiffMetaData = this.metadata.GetTiffMetadata();
TiffFrameMetadata firstFrameMetaData = framesMetadata.First();
this.SetBitsPerPixel(firstFrameMetaData);
this.tiffMetaData.Compression = firstFrameMetaData.Compression;
}
private void SetBitsPerPixel(TiffFrameMetadata firstFrameMetaData)
{
ushort[] bitsPerSample = firstFrameMetaData.BitsPerSample;
var bitsPerPixel = 0;
foreach (var bps in bitsPerSample)
{
bitsPerPixel += bps;
}
if (bitsPerPixel == 24)
{
this.tiffMetaData.BitsPerPixel = TiffBitsPerPixel.Pixel24;
}
else if (bitsPerPixel == 8)
{
this.tiffMetaData.BitsPerPixel = TiffBitsPerPixel.Pixel8;
}
else if (bitsPerPixel == 1)
{
this.tiffMetaData.BitsPerPixel = TiffBitsPerPixel.Pixel1;
}
}
private static TiffStream CreateStream(Stream stream)
{
TiffByteOrder byteOrder = ReadByteOrder(stream);

16
src/ImageSharp/Formats/Tiff/TiffDecoderHelpers.cs

@ -300,22 +300,6 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
private static void ParsePhotometric(this TiffDecoderCore options, TiffFrameMetadata entries)
{
/*
if (!entries.TryGetSingleNumber(ExifTag.PhotometricInterpretation, out uint photometricInterpretation))
{
if (entries.Compression == TiffCompression.Ccitt1D)
{
photometricInterpretation = (uint)TiffPhotometricInterpretation.WhiteIsZero;
}
else
{
TiffThrowHelper.ThrowNotSupported("The TIFF photometric interpretation entry is missing.");
}
}
options.PhotometricInterpretation = (TiffPhotometricInterpretation)photometricInterpretation;
/* */
// There is no default for PhotometricInterpretation, and it is required.
options.PhotometricInterpretation = entries.PhotometricInterpretation;
}

5
src/ImageSharp/Formats/Tiff/TiffMetadata.cs

@ -38,6 +38,11 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff
/// </summary>
public TiffBitsPerPixel BitsPerPixel { get; set; } = TiffBitsPerPixel.Pixel24;
/// <summary>
/// Gets or sets the compression used to create the TIFF file.
/// </summary>
public TiffCompression Compression { get; set; } = TiffCompression.None;
/// <summary>
/// Gets or sets the XMP profile.
/// </summary>

4
tests/ImageSharp.Tests/Formats/Bmp/BmpMetadataTests.cs

@ -16,12 +16,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
[Fact]
public void CloneIsDeep()
{
var meta = new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Pixel24 };
var meta = new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Pixel24, InfoHeaderType = BmpInfoHeaderType.Os2Version2 };
var clone = (BmpMetadata)meta.DeepClone();
clone.BitsPerPixel = BmpBitsPerPixel.Pixel32;
clone.InfoHeaderType = BmpInfoHeaderType.WinVersion2;
Assert.False(meta.BitsPerPixel.Equals(clone.BitsPerPixel));
Assert.False(meta.InfoHeaderType.Equals(clone.InfoHeaderType));
}
[Theory]

48
tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs

@ -11,6 +11,8 @@ using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit;
using static SixLabors.ImageSharp.Tests.TestImages.Tiff;
namespace SixLabors.ImageSharp.Tests.Formats.Tiff
{
[Trait("Format", "Tiff")]
@ -47,67 +49,67 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeRgb_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.Rgb);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeRgb_WithDeflateCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.Rgb, TiffEncoderCompression.Deflate);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeRgb_WithDeflateCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.Rgb, TiffEncoderCompression.Deflate, usePredictor: true);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeRgb_WithLzwCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.Rgb, TiffEncoderCompression.Lzw);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeRgb_WithLzwCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.Rgb, TiffEncoderCompression.Lzw, usePredictor: true);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeRgb_WithPackBitsCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.Rgb, TiffEncoderCompression.PackBits);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeGray_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel8, TiffEncodingMode.Gray);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeGray_WithDeflateCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel8, TiffEncodingMode.Gray, TiffEncoderCompression.Deflate);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeGray_WithDeflateCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel8, TiffEncodingMode.Gray, TiffEncoderCompression.Deflate, usePredictor: true);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeGray_WithLzwCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel8, TiffEncodingMode.Gray, TiffEncoderCompression.Lzw);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeGray_WithLzwCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel8, TiffEncodingMode.Gray, TiffEncoderCompression.Lzw, usePredictor: true);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeGray_WithPackBitsCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel8, TiffEncodingMode.Gray, TiffEncoderCompression.PackBits);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeColorPalette_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -117,7 +119,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeColorPalette_WithDeflateCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -127,7 +129,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeColorPalette_WithDeflateCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -137,7 +139,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeColorPalette_WithLzwCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -147,7 +149,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeColorPalette_WithLzwCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -157,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeColorPalette_WithPackBitsCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -184,27 +186,27 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
}
[Theory]
[WithFile(TestImages.Tiff.Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeBiColor_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel24, TiffEncodingMode.BiColor);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeBiColor_WithDeflateCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel1, TiffEncodingMode.BiColor, TiffEncoderCompression.Deflate);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeBiColor_WithPackBitsCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel1, TiffEncodingMode.BiColor, TiffEncoderCompression.PackBits);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeBiColor_WithCcittGroup3FaxCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel1, TiffEncodingMode.BiColor, TiffEncoderCompression.CcittGroup3Fax);
[Theory]
[WithFile(TestImages.Tiff.Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
public void TiffEncoder_EncodeBiColor_WithModifiedHuffmanCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Pixel1, TiffEncodingMode.BiColor, TiffEncoderCompression.ModifiedHuffman);

86
tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs

@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Formats.Experimental.Tiff;
using SixLabors.ImageSharp.Formats.Experimental.Tiff.Constants;
using SixLabors.ImageSharp.Metadata;
@ -8,16 +10,94 @@ using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using static SixLabors.ImageSharp.Tests.TestImages.Tiff;
namespace SixLabors.ImageSharp.Tests.Formats.Tiff
{
[Trait("Format", "Tiff")]
public class TiffMetadataTests
{
public static readonly string[] MetadataImages = TestImages.Tiff.Metadata;
[Fact]
public void CloneIsDeep()
{
var meta = new TiffMetadata
{
Compression = TiffCompression.Deflate,
BitsPerPixel = TiffBitsPerPixel.Pixel8,
ByteOrder = TiffByteOrder.BigEndian,
XmpProfile = new byte[3]
};
var clone = (TiffMetadata)meta.DeepClone();
clone.Compression = TiffCompression.None;
clone.BitsPerPixel = TiffBitsPerPixel.Pixel24;
clone.ByteOrder = TiffByteOrder.LittleEndian;
clone.XmpProfile = new byte[1];
Assert.False(meta.Compression == clone.Compression);
Assert.False(meta.BitsPerPixel == clone.BitsPerPixel);
Assert.False(meta.ByteOrder == clone.ByteOrder);
Assert.False(meta.XmpProfile.SequenceEqual(clone.XmpProfile));
}
[Theory]
[InlineData(Calliphora_BiColorUncompressed, TiffBitsPerPixel.Pixel1)]
[InlineData(GrayscaleUncompressed, TiffBitsPerPixel.Pixel8)]
[InlineData(RgbUncompressed, TiffBitsPerPixel.Pixel24)]
public void Identify_DetectsCorrectBitPerPixel(string imagePath, TiffBitsPerPixel expectedBitsPerPixel)
{
var testFile = TestFile.Create(imagePath);
using var stream = new MemoryStream(testFile.Bytes, false);
IImageInfo imageInfo = Image.Identify(stream);
Assert.NotNull(imageInfo);
TiffMetadata tiffMetadata = imageInfo.Metadata.GetTiffMetadata();
Assert.NotNull(tiffMetadata);
Assert.Equal(expectedBitsPerPixel, tiffMetadata.BitsPerPixel);
}
[Theory]
[InlineData(GrayscaleUncompressed, TiffCompression.None)]
[InlineData(RgbDeflate, TiffCompression.Deflate)]
[InlineData(SmallRgbLzw, TiffCompression.Lzw)]
[InlineData(Calliphora_Fax3Compressed, TiffCompression.CcittGroup3Fax)]
[InlineData(Calliphora_Fax4Compressed, TiffCompression.CcittGroup4Fax)]
[InlineData(Calliphora_HuffmanCompressed, TiffCompression.Ccitt1D)]
[InlineData(Calliphora_RgbPackbits, TiffCompression.PackBits)]
public void Identify_DetectsCorrectCompression(string imagePath, TiffCompression expectedCompression)
{
var testFile = TestFile.Create(imagePath);
using var stream = new MemoryStream(testFile.Bytes, false);
IImageInfo imageInfo = Image.Identify(stream);
Assert.NotNull(imageInfo);
TiffMetadata tiffMetadata = imageInfo.Metadata.GetTiffMetadata();
Assert.NotNull(tiffMetadata);
Assert.Equal(expectedCompression, tiffMetadata.Compression);
}
[Theory]
[InlineData(GrayscaleUncompressed, TiffByteOrder.BigEndian)]
[InlineData(LsbToMsbByteOrder, TiffByteOrder.LittleEndian)]
public void Identify_DetectsCorrectByteOrder(string imagePath, TiffByteOrder expectedByteOrder)
{
var testFile = TestFile.Create(imagePath);
using var stream = new MemoryStream(testFile.Bytes, false);
IImageInfo imageInfo = Image.Identify(stream);
Assert.NotNull(imageInfo);
TiffMetadata tiffMetadata = imageInfo.Metadata.GetTiffMetadata();
Assert.NotNull(tiffMetadata);
Assert.Equal(expectedByteOrder, tiffMetadata.ByteOrder);
}
[Theory]
[WithFile(TestImages.Tiff.SampleMetadata, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Tiff.SampleMetadata, PixelTypes.Rgba32, true)]
[WithFile(SampleMetadata, PixelTypes.Rgba32, false)]
[WithFile(SampleMetadata, PixelTypes.Rgba32, true)]
public void MetadataProfiles<TPixel>(TestImageProvider<TPixel> provider, bool ignoreMetadata)
where TPixel : unmanaged, IPixel<TPixel>
{

3
tests/ImageSharp.Tests/TestImages.cs

@ -517,6 +517,7 @@ namespace SixLabors.ImageSharp.Tests
public const string Calliphora_RgbPackbits = "Tiff/Calliphora_rgb_packbits.tiff";
public const string Calliphora_RgbUncompressed = "Tiff/Calliphora_rgb_uncompressed.tiff";
public const string Calliphora_Fax3Compressed = "Tiff/Calliphora_ccitt_fax3.tiff";
public const string Calliphora_Fax4Compressed = "Tiff/Calliphora_ccitt_fax4.tiff";
public const string Calliphora_HuffmanCompressed = "Tiff/Calliphora_huffman_rle.tiff";
public const string Calliphora_BiColorUncompressed = "Tiff/Calliphora_bicolor_uncompressed.tiff";
@ -559,6 +560,8 @@ namespace SixLabors.ImageSharp.Tests
public const string MultiframeDifferentSize = "Tiff/multipage_differentSize.tiff";
public const string MultiframeDifferentVariants = "Tiff/multipage_differentVariants.tiff";
public const string LsbToMsbByteOrder = "Tiff/b0350_lsb_to_msb.tiff";
public const string SampleMetadata = "Tiff/metadata_sample.tiff";
public static readonly string[] Multiframes = { MultiframeDeflateWithPreview, MultiframeLzwPredictor /*, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ };

3
tests/Images/Input/Tiff/Calliphora_ccitt_fax4.tiff

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7a2c95aec08b96bca30af344f7d9952a603a951802ce534a5f2c5f563795cbd2
size 117704

3
tests/Images/Input/Tiff/b0350_lsb_to_msb.tiff

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:37c6a28f460d8781fdc3bcf0cc9bd23f633b03899563546bfc6234a8478f67f0
size 68637
Loading…
Cancel
Save