From 11a4e2027b22304b690bf96afb2eba1a3c607aa9 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Fri, 21 May 2021 19:08:41 +0200 Subject: [PATCH] Add Compression, PhotometricInterpretation and Predictor to TiffFrameMetadata --- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 27 ++++----- .../Formats/Tiff/TiffEncoderCore.cs | 15 ++--- .../Formats/Tiff/TiffFrameMetadata.cs | 58 ++++++++++++++++++- .../Metadata/Profiles/Exif/ExifProfile.cs | 2 +- .../Formats/Tiff/TiffEncoderTests.cs | 34 +++++------ .../Formats/Tiff/TiffMetadataTests.cs | 57 +++++++++++++++--- 6 files changed, 134 insertions(+), 59 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 88a2d194d7..64df61bf0d 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -14,8 +14,6 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// internal static class TiffDecoderOptionsParser { - private const TiffPredictor DefaultPredictor = TiffPredictor.None; - private const TiffPlanarConfiguration DefaultPlanarConfiguration = TiffPlanarConfiguration.Chunky; /// @@ -23,8 +21,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// /// The options. /// The exif profile of the frame to decode. - /// The IFD entries container to read the image format information for. - public static void VerifyAndParse(this TiffDecoderCore options, ExifProfile exifProfile, TiffFrameMetadata entries) + /// The IFD entries container to read the image format information for current frame. + public static void VerifyAndParse(this TiffDecoderCore options, ExifProfile exifProfile, TiffFrameMetadata frameMetadata) { if (exifProfile.GetValue(ExifTag.TileOffsets)?.Value != null) { @@ -42,8 +40,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff TiffThrowHelper.ThrowNotSupported("The lower-order bits of the byte FillOrder is not supported."); } - TiffPredictor predictor = (TiffPredictor?)exifProfile.GetValue(ExifTag.Predictor)?.Value ?? DefaultPredictor; - if (predictor == TiffPredictor.FloatingPoint) + if (frameMetadata.Predictor == TiffPredictor.FloatingPoint) { TiffThrowHelper.ThrowNotSupported("TIFF images with FloatingPoint horizontal predictor are not supported."); } @@ -68,14 +65,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff VerifyRequiredFieldsArePresent(exifProfile); options.PlanarConfiguration = (TiffPlanarConfiguration?)exifProfile.GetValue(ExifTag.PlanarConfiguration)?.Value ?? DefaultPlanarConfiguration; - options.Predictor = predictor; - options.PhotometricInterpretation = exifProfile.GetValue(ExifTag.PhotometricInterpretation) != null ? - (TiffPhotometricInterpretation)exifProfile.GetValue(ExifTag.PhotometricInterpretation).Value : TiffPhotometricInterpretation.BlackIsZero; - options.BitsPerPixel = entries.BitsPerPixel != null ? (int)entries.BitsPerPixel.Value : (int)TiffBitsPerPixel.Bit24; - options.BitsPerSample = GetBitsPerSample(entries.BitsPerPixel); - - ParseColorType(options, exifProfile); - ParseCompression(options, exifProfile); + options.Predictor = frameMetadata.Predictor ?? TiffFrameMetadata.DefaultPredictor; + options.PhotometricInterpretation = frameMetadata.PhotometricInterpretation ?? TiffFrameMetadata.DefaultPhotometricInterpretation; + options.BitsPerPixel = frameMetadata.BitsPerPixel != null ? (int)frameMetadata.BitsPerPixel.Value : (int)TiffFrameMetadata.DefaultBitsPerPixel; + options.BitsPerSample = GetBitsPerSample(frameMetadata.BitsPerPixel); + + options.ParseColorType(exifProfile); + options.ParseCompression(frameMetadata.Compression, exifProfile); } private static void VerifyRequiredFieldsArePresent(ExifProfile exifProfile) @@ -222,9 +218,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff } } - private static void ParseCompression(this TiffDecoderCore options, ExifProfile exifProfile) + private static void ParseCompression(this TiffDecoderCore options, TiffCompression? compression, ExifProfile exifProfile) { - TiffCompression compression = exifProfile.GetValue(ExifTag.Compression) != null ? (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value : TiffCompression.None; switch (compression) { case TiffCompression.None: diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs index f9402e4d43..61dcd06256 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs @@ -111,19 +111,12 @@ namespace SixLabors.ImageSharp.Formats.Tiff : rootFramePhotometricInterpretation; ImageFrameMetadata rootFrameMetaData = image.Frames.RootFrame.Metadata; - ExifProfile rootFrameExifProfile = image.Frames.RootFrame.Metadata.ExifProfile; - TiffBitsPerPixel? rootFrameBitsPerPixel = rootFrameMetaData.GetTiffMetadata().BitsPerPixel; + TiffFrameMetadata rootFrameTiffMetaData = rootFrameMetaData.GetTiffMetadata(); + TiffBitsPerPixel? rootFrameBitsPerPixel = rootFrameTiffMetaData.BitsPerPixel; // If the user has not chosen a predictor or compression, set the values from the decoded image, if present. - if (!this.HorizontalPredictor.HasValue && rootFrameExifProfile?.GetValue(ExifTag.Predictor) != null) - { - this.HorizontalPredictor = (TiffPredictor)rootFrameExifProfile?.GetValue(ExifTag.Predictor).Value; - } - - if (!this.CompressionType.HasValue && rootFrameExifProfile?.GetValue(ExifTag.Compression) != null) - { - this.CompressionType = (TiffCompression)rootFrameExifProfile?.GetValue(ExifTag.Compression).Value; - } + this.HorizontalPredictor ??= rootFrameTiffMetaData.Predictor; + this.CompressionType ??= rootFrameTiffMetaData.Compression; this.SetBitsPerPixel(rootFrameBitsPerPixel, image.PixelType.BitsPerPixel, photometricInterpretation); this.SetPhotometricInterpretation(photometricInterpretation); diff --git a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs index c21238ad9f..baba5195da 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.Metadata.Profiles.Exif; namespace SixLabors.ImageSharp.Formats.Tiff @@ -10,6 +11,26 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// public class TiffFrameMetadata : IDeepCloneable { + /// + /// The default predictor is None. + /// + public const TiffPredictor DefaultPredictor = TiffPredictor.None; + + /// + /// The default bits per pixel is Bit24. + /// + public const TiffBitsPerPixel DefaultBitsPerPixel = TiffBitsPerPixel.Bit24; + + /// + /// The default compression is None. + /// + public const TiffCompression DefaultCompression = TiffCompression.None; + + /// + /// The default photometric interpretation is BlackIsZero. + /// + public const TiffPhotometricInterpretation DefaultPhotometricInterpretation = TiffPhotometricInterpretation.BlackIsZero; + /// /// Initializes a new instance of the class. /// @@ -28,6 +49,21 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// public TiffBitsPerPixel? BitsPerPixel { get; set; } + /// + /// Gets or sets the compression scheme used on the image data. + /// + public TiffCompression? Compression { get; set; } + + /// + /// Gets or sets the color space of the image data. + /// + public TiffPhotometricInterpretation? PhotometricInterpretation { get; set; } + + /// + /// Gets or sets a mathematical operator that is applied to the image data before an encoding scheme is applied. + /// + public TiffPredictor? Predictor { get; set; } + /// /// Returns a new instance parsed from the given Exif profile. /// @@ -52,6 +88,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff ushort[] bitsPerSample = profile.GetValue(ExifTag.BitsPerSample)?.Value; meta.BitsPerPixel = BitsPerPixelFromBitsPerSample(bitsPerSample); + meta.Compression = (TiffCompression?)profile.GetValue(ExifTag.Compression)?.Value ?? DefaultCompression; + meta.PhotometricInterpretation = (TiffPhotometricInterpretation?)profile.GetValue(ExifTag.PhotometricInterpretation)?.Value ?? DefaultPhotometricInterpretation; + meta.Predictor = (TiffPredictor?)profile.GetValue(ExifTag.Predictor)?.Value ?? DefaultPredictor; + + profile.RemoveValue(ExifTag.Compression); + profile.RemoveValue(ExifTag.PhotometricInterpretation); + profile.RemoveValue(ExifTag.Predictor); } /// @@ -63,7 +106,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff { if (bitsPerSample == null) { - return TiffBitsPerPixel.Bit24; + return DefaultBitsPerPixel; } int bitsPerPixel = 0; @@ -76,6 +119,17 @@ namespace SixLabors.ImageSharp.Formats.Tiff } /// - public IDeepCloneable DeepClone() => new TiffFrameMetadata(this); + public IDeepCloneable DeepClone() + { + var clone = new TiffFrameMetadata + { + BitsPerPixel = this.BitsPerPixel, + Compression = this.Compression, + PhotometricInterpretation = this.PhotometricInterpretation, + Predictor = this.Predictor + }; + + return clone; + } } } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index 39c8c22936..9265314edb 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif /// /// The tag of the EXIF value. /// - /// The . + /// True, if the value was removed, otherwise false. /// public bool RemoveValue(ExifTag tag) { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 99a74182d5..ce4b4f1659 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -48,15 +48,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff // assert memStream.Position = 0; using var output = Image.Load(Configuration, memStream); - ExifProfile exifProfile = output.Frames.RootFrame.Metadata.ExifProfile; - var frameMetaData = TiffFrameMetadata.Parse(exifProfile); + TiffFrameMetadata frameMetaData = output.Frames.RootFrame.Metadata.GetTiffMetadata(); Assert.Equal(expectedBitsPerPixel, frameMetaData.BitsPerPixel); - Assert.Equal(TiffCompression.None, (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value); + Assert.Equal(TiffCompression.None, frameMetaData.Compression); } [Theory] [InlineData(TiffBitsPerPixel.Bit24)] - [InlineData(TiffBitsPerPixel.Bit8)] + [InlineData(TiffBitsPerPixel.Bit8)] [InlineData(TiffBitsPerPixel.Bit4)] [InlineData(TiffBitsPerPixel.Bit1)] public void EncoderOptions_SetBitPerPixel_Works(TiffBitsPerPixel bitsPerPixel) @@ -73,10 +72,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff memStream.Position = 0; using var output = Image.Load(Configuration, memStream); - ExifProfile exifProfile = output.Frames.RootFrame.Metadata.ExifProfile; TiffFrameMetadata frameMetaData = output.Frames.RootFrame.Metadata.GetTiffMetadata(); Assert.Equal(bitsPerPixel, frameMetaData.BitsPerPixel); - Assert.Equal(TiffCompression.None, (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value); + Assert.Equal(TiffCompression.None, frameMetaData.Compression); } [Theory] @@ -112,10 +110,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff // assert memStream.Position = 0; using var output = Image.Load(Configuration, memStream); - ExifProfile exifProfile = output.Frames.RootFrame.Metadata.ExifProfile; TiffFrameMetadata rootFrameMetaData = output.Frames.RootFrame.Metadata.GetTiffMetadata(); Assert.Equal(expectedBitsPerPixel, rootFrameMetaData.BitsPerPixel); - Assert.Equal(expectedCompression, (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value); + Assert.Equal(expectedCompression, rootFrameMetaData.Compression); } [Theory] @@ -151,7 +148,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff var tiffEncoder = new TiffEncoder(); using Image input = new Image(10, 10); using var memStream = new MemoryStream(); - var expectedBitsPerPixel = TiffBitsPerPixel.Bit8; + TiffBitsPerPixel expectedBitsPerPixel = TiffBitsPerPixel.Bit8; // act input.Save(memStream, tiffEncoder); @@ -183,8 +180,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff // assert memStream.Position = 0; using var output = Image.Load(Configuration, memStream); - ExifProfile exifProfile = output.Frames.RootFrame.Metadata.ExifProfile; - Assert.Equal(expectedCompression, (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value); + Assert.Equal(expectedCompression, output.Frames.RootFrame.Metadata.GetTiffMetadata().Compression); } [Theory] @@ -206,8 +202,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff // assert memStream.Position = 0; using var output = Image.Load(Configuration, memStream); - ExifProfile exifProfile = output.Frames.RootFrame.Metadata.ExifProfile; - Assert.Equal(expectedPredictor, (TiffPredictor)exifProfile.GetValue(ExifTag.Predictor).Value); + TiffFrameMetadata frameMetadata = output.Frames.RootFrame.Metadata.GetTiffMetadata(); + Assert.Equal(expectedPredictor, frameMetadata.Predictor); } [Theory] @@ -229,10 +225,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff // assert memStream.Position = 0; using var output = Image.Load(Configuration, memStream); - ExifProfile exifProfile = output.Frames.RootFrame.Metadata.ExifProfile; - var frameMetaData = TiffFrameMetadata.Parse(exifProfile); + TiffFrameMetadata frameMetaData = output.Frames.RootFrame.Metadata.GetTiffMetadata(); Assert.Equal(TiffBitsPerPixel.Bit1, frameMetaData.BitsPerPixel); - Assert.Equal(expectedCompression, (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value); + Assert.Equal(expectedCompression, frameMetaData.Compression); } [Theory] @@ -402,9 +397,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff var tiffEncoder = new TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; using Image input = provider.GetImage(); using var memStream = new MemoryStream(); - ExifProfile exifProfileInput = input.Frames.RootFrame.Metadata.ExifProfile; - var inputCompression = (TiffCompression)exifProfileInput.GetValue(ExifTag.Compression).Value; - var inputMeta = TiffFrameMetadata.Parse(exifProfileInput); + TiffFrameMetadata inputMeta = input.Frames.RootFrame.Metadata.GetTiffMetadata(); + TiffCompression inputCompression = inputMeta.Compression ?? TiffCompression.None; // act input.Save(memStream, tiffEncoder); @@ -413,7 +407,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff memStream.Position = 0; using var output = Image.Load(Configuration, memStream); ExifProfile exifProfileOutput = output.Frames.RootFrame.Metadata.ExifProfile; - var outputMeta = TiffFrameMetadata.Parse(exifProfileOutput); + TiffFrameMetadata outputMeta = output.Frames.RootFrame.Metadata.GetTiffMetadata(); ImageFrame rootFrame = output.Frames.RootFrame; Number rowsPerStrip = exifProfileOutput.GetValue(ExifTag.RowsPerStrip) != null ? exifProfileOutput.GetValue(ExifTag.RowsPerStrip).Value : TiffConstants.RowsPerStripInfinity; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs index 25f0521f90..7f799e73c4 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs @@ -45,6 +45,41 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff Assert.False(meta.ByteOrder == clone.ByteOrder); } + [Theory] + [WithFile(SampleMetadata, PixelTypes.Rgba32)] + public void TiffFrameMetadata_CloneIsDeep(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TiffDecoder)) + { + TiffFrameMetadata meta = image.Frames.RootFrame.Metadata.GetTiffMetadata(); + var cloneSameAsSampleMetaData = (TiffFrameMetadata)meta.DeepClone(); + VerifyExpectedTiffFrameMetaDataIsPresent(cloneSameAsSampleMetaData); + + var clone = (TiffFrameMetadata)meta.DeepClone(); + + clone.BitsPerPixel = TiffBitsPerPixel.Bit8; + clone.Compression = TiffCompression.None; + clone.PhotometricInterpretation = TiffPhotometricInterpretation.CieLab; + clone.Predictor = TiffPredictor.Horizontal; + + Assert.False(meta.BitsPerPixel == clone.BitsPerPixel); + Assert.False(meta.Compression == clone.Compression); + Assert.False(meta.PhotometricInterpretation == clone.PhotometricInterpretation); + Assert.False(meta.Predictor == clone.Predictor); + } + } + + private static void VerifyExpectedTiffFrameMetaDataIsPresent(TiffFrameMetadata frameMetaData) + { + Assert.NotNull(frameMetaData); + Assert.NotNull(frameMetaData.BitsPerPixel); + Assert.Equal(TiffBitsPerSample.Bit4, (TiffBitsPerSample)frameMetaData.BitsPerPixel); + Assert.Equal(TiffCompression.Lzw, frameMetaData.Compression); + Assert.Equal(TiffPhotometricInterpretation.PaletteColor, frameMetaData.PhotometricInterpretation); + Assert.Equal(TiffPredictor.None, frameMetaData.Predictor); + } + [Theory] [InlineData(Calliphora_BiColorUncompressed, 1)] [InlineData(GrayscaleUncompressed, 8)] @@ -99,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff Assert.NotNull(rootFrameMetaData.XmpProfile); Assert.NotNull(rootFrameMetaData.ExifProfile); Assert.Equal(2599, rootFrameMetaData.XmpProfile.Length); - Assert.Equal(30, rootFrameMetaData.ExifProfile.Values.Count); + Assert.Equal(27, rootFrameMetaData.ExifProfile.Values.Count); } } } @@ -132,9 +167,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff Assert.Equal(2599, rootFrame.Metadata.XmpProfile.Length); ExifProfile exifProfile = rootFrame.Metadata.ExifProfile; + TiffFrameMetadata tiffFrameMetadata = rootFrame.Metadata.GetTiffMetadata(); Assert.NotNull(exifProfile); - Assert.Equal(30, exifProfile.Values.Count); - Assert.Equal(TiffCompression.Lzw, (TiffCompression)exifProfile.GetValue(ExifTag.Compression).Value); + + // The original exifProfile has 30 values, but 3 of those values will be stored in the TiffFrameMetaData + // and removed from the profile on decode. + Assert.Equal(27, exifProfile.Values.Count); + Assert.Equal(TiffCompression.Lzw, tiffFrameMetadata.Compression); Assert.Equal("This is Название", exifProfile.GetValue(ExifTag.ImageDescription).Value); Assert.Equal("This is Изготовитель камеры", exifProfile.GetValue(ExifTag.Make).Value); Assert.Equal("This is Модель камеры", exifProfile.GetValue(ExifTag.Model).Value); @@ -153,7 +192,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff Assert.Null(exifProfile.GetValue(ExifTag.ExtraSamples)?.Value); Assert.Equal(32u, exifProfile.GetValue(ExifTag.RowsPerStrip).Value); Assert.Null(exifProfile.GetValue(ExifTag.SampleFormat)); - Assert.Equal(TiffPredictor.None, (TiffPredictor?)exifProfile.GetValue(ExifTag.Predictor)?.Value); + Assert.Equal(TiffPredictor.None, tiffFrameMetadata.Predictor); Assert.Equal(PixelResolutionUnit.PixelsPerInch, UnitConverter.ExifProfileToResolutionUnit(exifProfile)); ushort[] colorMap = exifProfile.GetValue(ExifTag.ColorMap)?.Value; Assert.NotNull(colorMap); @@ -162,7 +201,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff Assert.Equal(14392, colorMap[1]); Assert.Equal(58596, colorMap[46]); Assert.Equal(3855, colorMap[47]); - Assert.Equal(TiffPhotometricInterpretation.PaletteColor, (TiffPhotometricInterpretation)exifProfile.GetValue(ExifTag.PhotometricInterpretation).Value); + Assert.Equal(TiffPhotometricInterpretation.PaletteColor, tiffFrameMetadata.PhotometricInterpretation); Assert.Equal(1u, exifProfile.GetValue(ExifTag.SamplesPerPixel).Value); ImageMetadata imageMetaData = image.Metadata; @@ -213,12 +252,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff using Image image = provider.GetImage(new TiffDecoder() { IgnoreMetadata = false }); ImageMetadata inputMetaData = image.Metadata; - var frameMetaInput = TiffFrameMetadata.Parse(image.Frames.RootFrame.Metadata.ExifProfile); ImageFrame rootFrameInput = image.Frames.RootFrame; + TiffFrameMetadata frameMetaInput = rootFrameInput.Metadata.GetTiffMetadata(); byte[] xmpProfileInput = rootFrameInput.Metadata.XmpProfile; ExifProfile exifProfileInput = rootFrameInput.Metadata.ExifProfile; - Assert.Equal(TiffCompression.Lzw, (TiffCompression)exifProfileInput.GetValue(ExifTag.Compression).Value); + Assert.Equal(TiffCompression.Lzw, frameMetaInput.Compression); Assert.Equal(TiffBitsPerPixel.Bit4, frameMetaInput.BitsPerPixel); // Save to Tiff @@ -232,12 +271,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff ImageMetadata encodedImageMetaData = encodedImage.Metadata; ImageFrame rootFrameEncodedImage = encodedImage.Frames.RootFrame; - var tiffMetaDataEncodedRootFrame = TiffFrameMetadata.Parse(rootFrameEncodedImage.Metadata.ExifProfile); + TiffFrameMetadata tiffMetaDataEncodedRootFrame = rootFrameEncodedImage.Metadata.GetTiffMetadata(); ExifProfile encodedImageExifProfile = rootFrameEncodedImage.Metadata.ExifProfile; byte[] encodedImageXmpProfile = rootFrameEncodedImage.Metadata.XmpProfile; Assert.Equal(TiffBitsPerPixel.Bit4, tiffMetaDataEncodedRootFrame.BitsPerPixel); - Assert.Equal(TiffCompression.Lzw, (TiffCompression)encodedImageExifProfile.GetValue(ExifTag.Compression).Value); + Assert.Equal(TiffCompression.Lzw, tiffMetaDataEncodedRootFrame.Compression); Assert.Equal(inputMetaData.HorizontalResolution, encodedImageMetaData.HorizontalResolution); Assert.Equal(inputMetaData.VerticalResolution, encodedImageMetaData.VerticalResolution);