Browse Source

Add lossless encode test which checks the expected bytes count of the encoded file

pull/1873/head
Brian Popow 4 years ago
parent
commit
3780ca78e0
  1. 18
      tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs

18
tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs

@ -101,6 +101,24 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
image.VerifyEncoder(provider, "webp", testOutputDetails, encoder);
}
[Theory]
[WithFile(Lossy.NoFilter06, PixelTypes.Rgba32, 15114)]
public void Encode_Lossless_WithBestQuality_HasExpectedSize<TPixel>(TestImageProvider<TPixel> provider, int expectedBytes)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossless,
Method = WebpEncodingMethod.BestQuality
};
using Image<TPixel> image = provider.GetImage();
using var memoryStream = new MemoryStream();
image.Save(memoryStream, encoder);
Assert.Equal(memoryStream.Length, expectedBytes);
}
[Theory]
[WithFile(RgbTestPattern100x100, PixelTypes.Rgba32, 85)]
[WithFile(RgbTestPattern100x100, PixelTypes.Rgba32, 60)]

Loading…
Cancel
Save