mirror of https://github.com/SixLabors/ImageSharp
8 changed files with 77 additions and 30 deletions
@ -1,21 +0,0 @@ |
|||||
using System; |
|
||||
using SixLabors.ImageSharp.Formats.Bmp; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Tests.Formats.WebP |
|
||||
{ |
|
||||
public class WebPFileHeaderTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void TestWrite() |
|
||||
{ |
|
||||
var header = new BmpFileHeader(1, 2, 3, 4); |
|
||||
|
|
||||
var buffer = new byte[14]; |
|
||||
|
|
||||
header.WriteTo(buffer); |
|
||||
|
|
||||
Assert.Equal("AQACAAAAAwAAAAQAAAA=", Convert.ToBase64String(buffer)); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,57 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.Formats.WebP; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using Xunit; |
||||
|
|
||||
|
// ReSharper disable InconsistentNaming
|
||||
|
namespace SixLabors.ImageSharp.Tests.Formats.WebP |
||||
|
{ |
||||
|
public class WebPMetadataTests |
||||
|
{ |
||||
|
[Theory] |
||||
|
[WithFile(TestImages.WebP.Lossless.WithExif, PixelTypes.Rgba32, false)] |
||||
|
[WithFile(TestImages.WebP.Lossy.WithExif, PixelTypes.Rgba32, true)] |
||||
|
public void IgnoreMetadata_ControlsWhetherExifIsParsed<TPixel>(TestImageProvider<TPixel> provider, bool ignoreMetadata) |
||||
|
where TPixel : unmanaged, IPixel<TPixel> |
||||
|
{ |
||||
|
var decoder = new WebPDecoder { IgnoreMetadata = ignoreMetadata }; |
||||
|
|
||||
|
using (Image<TPixel> image = provider.GetImage(decoder)) |
||||
|
{ |
||||
|
if (ignoreMetadata) |
||||
|
{ |
||||
|
Assert.Null(image.Metadata.ExifProfile); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Assert.NotNull(image.Metadata.ExifProfile); |
||||
|
Assert.NotEmpty(image.Metadata.ExifProfile.Values); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFile(TestImages.WebP.Lossless.WithIccp, PixelTypes.Rgba32, false)] |
||||
|
[WithFile(TestImages.WebP.Lossy.WithIccp, PixelTypes.Rgba32, true)] |
||||
|
public void IgnoreMetadata_ControlsWhetherIccpIsParsed<TPixel>(TestImageProvider<TPixel> provider, bool ignoreMetadata) |
||||
|
where TPixel : unmanaged, IPixel<TPixel> |
||||
|
{ |
||||
|
var decoder = new WebPDecoder { IgnoreMetadata = ignoreMetadata }; |
||||
|
|
||||
|
using (Image<TPixel> image = provider.GetImage(decoder)) |
||||
|
{ |
||||
|
if (ignoreMetadata) |
||||
|
{ |
||||
|
Assert.Null(image.Metadata.IccProfile); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Assert.NotNull(image.Metadata.IccProfile); |
||||
|
Assert.NotEmpty(image.Metadata.IccProfile.Entries); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue