Browse Source

Moved legacy exif data loading test from PngDecoderTests to PngMetadataTests.

pull/1877/head
WINDEV2110EVAL\User 4 years ago
parent
commit
c8e2902be2
  1. 19
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  2. 26
      tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs

19
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

@ -444,24 +444,5 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
"Disco")
.Dispose();
}
[Theory]
[WithFile(TestImages.Png.Issue1875, PixelTypes.Rgba32)]
public void PngDecoder_CanDecode_LegacyTextExifChunk(TestImageProvider<Rgba32> provider)
{
using Image<Rgba32> image = provider.GetImage(PngDecoder);
Assert.Equal(0, image.Metadata.ExifProfile.InvalidTags.Count);
Assert.Equal(3, image.Metadata.ExifProfile.Values.Count);
Assert.Equal(
"A colorful tiling of blue, red, yellow, and green 4x4 pixel blocks.",
image.Metadata.ExifProfile.GetValue(ImageSharp.Metadata.Profiles.Exif.ExifTag.ImageDescription).Value);
Assert.Equal(
"Duplicated from basn3p02.png, then image metadata modified with exiv2",
image.Metadata.ExifProfile.GetValue(ImageSharp.Metadata.Profiles.Exif.ExifTag.ImageHistory).Value);
Assert.Equal(42, (int)image.Metadata.ExifProfile.GetValue(ImageSharp.Metadata.Profiles.Exif.ExifTag.ImageNumber).Value);
}
}
}

26
tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs

@ -289,5 +289,31 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
Assert.Contains(meta.TextData, m => m.Keyword is "NoLang" && m.Value is "this text chunk is missing a language tag");
Assert.Contains(meta.TextData, m => m.Keyword is "NoTranslatedKeyword" && m.Value is "dieser chunk hat kein übersetztes Schlüßelwort");
}
[Theory]
[InlineData(TestImages.Png.Issue1875)]
public void Identify_ReadsLegacyExifData(string imagePath)
{
var testFile = TestFile.Create(imagePath);
using (var stream = new MemoryStream(testFile.Bytes, false))
{
IImageInfo imageInfo = Image.Identify(stream);
Assert.NotNull(imageInfo);
Assert.NotNull(imageInfo.Metadata.ExifProfile);
ExifProfile exif = imageInfo.Metadata.ExifProfile;
Assert.Equal(0, exif.InvalidTags.Count);
Assert.Equal(3, exif.Values.Count);
Assert.Equal(
"A colorful tiling of blue, red, yellow, and green 4x4 pixel blocks.",
exif.GetValue(ExifTag.ImageDescription).Value);
Assert.Equal(
"Duplicated from basn3p02.png, then image metadata modified with exiv2",
exif.GetValue(ExifTag.ImageHistory).Value);
Assert.Equal(42, (int)exif.GetValue(ExifTag.ImageNumber).Value);
}
}
}
}

Loading…
Cancel
Save