|
|
|
@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png |
|
|
|
public class PngMetadataTests |
|
|
|
{ |
|
|
|
public static readonly TheoryData<string, int, int, PixelResolutionUnit> RatioFiles = |
|
|
|
new TheoryData<string, int, int, PixelResolutionUnit> |
|
|
|
new() |
|
|
|
{ |
|
|
|
{ TestImages.Png.Splash, 11810, 11810, PixelResolutionUnit.PixelsPerMeter }, |
|
|
|
{ TestImages.Png.Ratio1x4, 1, 4, PixelResolutionUnit.AspectRatio }, |
|
|
|
@ -222,6 +222,33 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] |
|
|
|
public void Encode_PreservesColorProfile<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> input = provider.GetImage(new PngDecoder())) |
|
|
|
{ |
|
|
|
ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; |
|
|
|
byte[] expectedProfileBytes = expectedProfile.ToByteArray(); |
|
|
|
|
|
|
|
using (var memStream = new MemoryStream()) |
|
|
|
{ |
|
|
|
input.Save(memStream, new PngEncoder()); |
|
|
|
|
|
|
|
memStream.Position = 0; |
|
|
|
using (var output = Image.Load<Rgba32>(memStream)) |
|
|
|
{ |
|
|
|
ImageSharp.Metadata.Profiles.Icc.IccProfile actualProfile = output.Metadata.IccProfile; |
|
|
|
byte[] actualProfileBytes = actualProfile.ToByteArray(); |
|
|
|
|
|
|
|
Assert.NotNull(actualProfile); |
|
|
|
Assert.Equal(expectedProfileBytes, actualProfileBytes); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[MemberData(nameof(RatioFiles))] |
|
|
|
public void Identify_VerifyRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit) |
|
|
|
|