Browse Source

Use Webp everywhere

pull/1552/head
James Jackson-South 5 years ago
parent
commit
f88a95c0f3
  1. 6
      src/ImageSharp/Formats/Webp/AlphaDecoder.cs
  2. 2
      src/ImageSharp/Formats/Webp/BitWriter/BitWriterBase.cs
  3. 4
      src/ImageSharp/Formats/Webp/IWebpEncoderOptions.cs
  4. 8
      src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs
  5. 6
      src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs
  6. 12
      src/ImageSharp/Formats/Webp/Readme.md
  7. 2
      src/ImageSharp/Formats/Webp/WebpAlphaCompressionMethod.cs
  8. 2
      src/ImageSharp/Formats/Webp/WebpChunkType.cs
  9. 6
      src/ImageSharp/Formats/Webp/WebpConstants.cs
  10. 8
      src/ImageSharp/Formats/Webp/WebpDecoderCore.cs
  11. 4
      src/ImageSharp/Formats/Webp/WebpEncoder.cs
  12. 6
      src/ImageSharp/Formats/Webp/WebpEncoderCore.cs
  13. 2
      src/ImageSharp/Formats/Webp/WebpFormat.cs
  14. 6
      src/ImageSharp/Formats/Webp/WebpImageFormatDetector.cs
  15. 2
      src/ImageSharp/Formats/Webp/WebpMetadata.cs
  16. 40
      tests/ImageSharp.Benchmarks/Codecs/DecodeWebp.cs
  17. 8
      tests/ImageSharp.Benchmarks/Codecs/EncodeWebp.cs
  18. 4
      tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs
  19. 2
      tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs
  20. 2
      tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs
  21. 20
      tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs
  22. 2
      tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs
  23. 2
      tests/ImageSharp.Tests/TestImages.cs

6
src/ImageSharp/Formats/Webp/AlphaDecoder.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
if (this.Compressed)
{
var bitReader = new Vp8LBitReader(data);
this.LosslessDecoder = new WebPLosslessDecoder(bitReader, memoryAllocator, configuration);
this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration);
this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true);
this.Use8BDecode = this.Vp8LDec.Transforms.Count > 0 && Is8BOptimizable(this.Vp8LDec.Metadata);
}
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// <summary>
/// Gets the Vp8L decoder which is used to de compress the alpha channel, if needed.
/// </summary>
private WebPLosslessDecoder LosslessDecoder { get; }
private WebpLosslessDecoder LosslessDecoder { get; }
/// <summary>
/// Gets a value indicating whether the decoding needs 1 byte per pixel for decoding.
@ -260,7 +260,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
// Extract alpha (which is stored in the green plane).
int pixelCount = width * numRowsToProcess;
WebPLosslessDecoder.ApplyInverseTransforms(dec, input, this.memoryAllocator);
WebpLosslessDecoder.ApplyInverseTransforms(dec, input, this.memoryAllocator);
ExtractGreen(input, output, pixelCount);
this.AlphaApplyFilter(0, numRowsToProcess, output, width);
}

2
src/ImageSharp/Formats/Webp/BitWriter/BitWriterBase.cs

@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.BitWriter
stream.Write(WebpConstants.RiffFourCc);
BinaryPrimitives.WriteUInt32LittleEndian(buf, riffSize);
stream.Write(buf);
stream.Write(WebpConstants.WebPHeader);
stream.Write(WebpConstants.WebpHeader);
}
/// <summary>

4
src/ImageSharp/Formats/Webp/IWebpEncoderOptions.cs

@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// <summary>
/// Configuration options for use during webp encoding.
/// </summary>
internal interface IWebPEncoderOptions
internal interface IWebpEncoderOptions
{
/// <summary>
/// Gets a value indicating whether lossy compression should be used.
@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
int Method { get; }
/// <summary>
/// Gets a value indicating whether the alpha plane should be compressed with WebP lossless format.
/// Gets a value indicating whether the alpha plane should be compressed with Webp lossless format.
/// </summary>
bool UseAlphaCompression { get; }

8
src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
/// The lossless specification can be found here:
/// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification
/// </remarks>
internal sealed class WebPLosslessDecoder
internal sealed class WebpLosslessDecoder
{
/// <summary>
/// A bit reader for reading lossless webp streams.
@ -75,12 +75,12 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
};
/// <summary>
/// Initializes a new instance of the <see cref="WebPLosslessDecoder"/> class.
/// Initializes a new instance of the <see cref="WebpLosslessDecoder"/> class.
/// </summary>
/// <param name="bitReader">Bitreader to read from the stream.</param>
/// <param name="memoryAllocator">Used for allocating memory during processing operations.</param>
/// <param name="configuration">The configuration.</param>
public WebPLosslessDecoder(Vp8LBitReader bitReader, MemoryAllocator memoryAllocator, Configuration configuration)
public WebpLosslessDecoder(Vp8LBitReader bitReader, MemoryAllocator memoryAllocator, Configuration configuration)
{
this.bitReader = bitReader;
this.memoryAllocator = memoryAllocator;
@ -675,7 +675,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
}
/// <summary>
/// A WebP lossless image can go through four different types of transformation before being entropy encoded.
/// A Webp lossless image can go through four different types of transformation before being entropy encoded.
/// This will reverse the transformations, if any are present.
/// </summary>
/// <param name="decoder">The decoder holding the transformation infos.</param>

6
src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
/// <remarks>
/// The lossy specification can be found here: https://tools.ietf.org/html/rfc6386
/// </remarks>
internal sealed class WebPLossyDecoder
internal sealed class WebpLossyDecoder
{
/// <summary>
/// A bit reader for reading lossy webp streams.
@ -35,12 +35,12 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
private readonly Configuration configuration;
/// <summary>
/// Initializes a new instance of the <see cref="WebPLossyDecoder"/> class.
/// Initializes a new instance of the <see cref="WebpLossyDecoder"/> class.
/// </summary>
/// <param name="bitReader">Bitreader to read from the stream.</param>
/// <param name="memoryAllocator">Used for allocating memory during processing operations.</param>
/// <param name="configuration">The configuration.</param>
public WebPLossyDecoder(Vp8BitReader bitReader, MemoryAllocator memoryAllocator, Configuration configuration)
public WebpLossyDecoder(Vp8BitReader bitReader, MemoryAllocator memoryAllocator, Configuration configuration)
{
this.bitReader = bitReader;
this.memoryAllocator = memoryAllocator;

12
src/ImageSharp/Formats/Webp/Readme.md

@ -1,10 +1,10 @@
# WebP Format
# Webp Format
Reference implementation, specification and stuff like that:
- [google webp introduction](https://developers.google.com/speed/webp)
- [WebP Spec 1.0.3](https://chromium.googlesource.com/webm/libwebp/+/v1.0.3/doc/webp-container-spec.txt)
- [WebP VP8 Spec, Lossy](http://tools.ietf.org/html/rfc6386)
- [WebP VP8L Spec, Lossless](https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification)
- [WebP filefront](https://wiki.fileformat.com/image/webp/)
- [WebP test data](https://github.com/webmproject/libwebp-test-data/)
- [Webp Spec 1.0.3](https://chromium.googlesource.com/webm/libwebp/+/v1.0.3/doc/webp-container-spec.txt)
- [Webp VP8 Spec, Lossy](http://tools.ietf.org/html/rfc6386)
- [Webp VP8L Spec, Lossless](https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification)
- [Webp filefront](https://wiki.fileformat.com/image/webp/)
- [Webp test data](https://github.com/webmproject/libwebp-test-data/)

2
src/ImageSharp/Formats/Webp/WebpAlphaCompressionMethod.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
NoCompression = 0,
/// <summary>
/// Compressed using the WebP lossless format.
/// Compressed using the Webp lossless format.
/// </summary>
WebpLosslessCompression = 1
}

2
src/ImageSharp/Formats/Webp/WebpChunkType.cs

@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// <summary>
/// Contains a list of different webp chunk types.
/// </summary>
/// <remarks>See WebP Container Specification for more details: https://developers.google.com/speed/webp/docs/riff_container </remarks>
/// <remarks>See Webp Container Specification for more details: https://developers.google.com/speed/webp/docs/riff_container </remarks>
internal enum WebpChunkType : uint
{
/// <summary>

6
src/ImageSharp/Formats/Webp/WebpConstants.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
internal static class WebpConstants
{
/// <summary>
/// The list of file extensions that equate to WebP.
/// The list of file extensions that equate to Webp.
/// </summary>
public static readonly IEnumerable<string> FileExtensions = new[] { "webp" };
@ -80,9 +80,9 @@ namespace SixLabors.ImageSharp.Formats.Webp
};
/// <summary>
/// The header bytes identifying a WebP.
/// The header bytes identifying a Webp.
/// </summary>
public static readonly byte[] WebPHeader =
public static readonly byte[] WebpHeader =
{
0x57, // W
0x45, // E

8
src/ImageSharp/Formats/Webp/WebpDecoderCore.cs

@ -97,12 +97,12 @@ namespace SixLabors.ImageSharp.Formats.Webp
Buffer2D<TPixel> pixels = image.GetRootFramePixelBuffer();
if (this.webImageInfo.IsLossless)
{
var losslessDecoder = new WebPLosslessDecoder(this.webImageInfo.Vp8LBitReader, this.memoryAllocator, this.Configuration);
var losslessDecoder = new WebpLosslessDecoder(this.webImageInfo.Vp8LBitReader, this.memoryAllocator, this.Configuration);
losslessDecoder.Decode(pixels, image.Width, image.Height);
}
else
{
var lossyDecoder = new WebPLossyDecoder(this.webImageInfo.Vp8BitReader, this.memoryAllocator, this.Configuration);
var lossyDecoder = new WebpLossyDecoder(this.webImageInfo.Vp8BitReader, this.memoryAllocator, this.Configuration);
lossyDecoder.Decode(pixels, image.Width, image.Height, this.webImageInfo);
}
@ -502,7 +502,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
return chunkType;
}
throw new ImageFormatException("Invalid WebP data.");
throw new ImageFormatException("Invalid Webp data.");
}
/// <summary>
@ -518,7 +518,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
return (chunkSize % 2 == 0) ? chunkSize : chunkSize + 1;
}
throw new ImageFormatException("Invalid WebP data.");
throw new ImageFormatException("Invalid Webp data.");
}
/// <summary>

4
src/ImageSharp/Formats/Webp/WebpEncoder.cs

@ -10,9 +10,9 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Webp
{
/// <summary>
/// Image encoder for writing an image to a stream in the WebP format.
/// Image encoder for writing an image to a stream in the Webp format.
/// </summary>
public sealed class WebpEncoder : IImageEncoder, IWebPEncoderOptions
public sealed class WebpEncoder : IImageEncoder, IWebpEncoderOptions
{
/// <inheritdoc/>
public bool Lossy { get; set; }

6
src/ImageSharp/Formats/Webp/WebpEncoderCore.cs

@ -12,7 +12,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Webp
{
/// <summary>
/// Image encoder for writing an image to a stream in the WebP format.
/// Image encoder for writing an image to a stream in the Webp format.
/// </summary>
internal sealed class WebpEncoderCore : IImageEncoderInternals
{
@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// <summary>
/// TODO: not used at the moment.
/// Indicating whether the alpha plane should be compressed with WebP lossless format.
/// Indicating whether the alpha plane should be compressed with Webp lossless format.
/// </summary>
private readonly bool alphaCompression;
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// </summary>
/// <param name="options">The encoder options.</param>
/// <param name="memoryAllocator">The memory manager.</param>
public WebpEncoderCore(IWebPEncoderOptions options, MemoryAllocator memoryAllocator)
public WebpEncoderCore(IWebpEncoderOptions options, MemoryAllocator memoryAllocator)
{
this.memoryAllocator = memoryAllocator;
this.alphaCompression = options.UseAlphaCompression;

2
src/ImageSharp/Formats/Webp/WebpFormat.cs

@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
public static WebpFormat Instance { get; } = new WebpFormat();
/// <inheritdoc/>
public string Name => "WebP";
public string Name => "Webp";
/// <inheritdoc/>
public string DefaultMimeType => "image/webp";

6
src/ImageSharp/Formats/Webp/WebpImageFormatDetector.cs

@ -6,7 +6,7 @@ using System;
namespace SixLabors.ImageSharp.Formats.Webp
{
/// <summary>
/// Detects WebP file headers.
/// Detects Webp file headers.
/// </summary>
public sealed class WebpImageFormatDetector : IImageFormatDetector
{
@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// <inheritdoc />
public IImageFormat DetectFormat(ReadOnlySpan<byte> header) => this.IsSupportedFileFormat(header) ? WebpFormat.Instance : null;
private bool IsSupportedFileFormat(ReadOnlySpan<byte> header) => header.Length >= this.HeaderSize && this.IsRiffContainer(header) && this.IsWebPFile(header);
private bool IsSupportedFileFormat(ReadOnlySpan<byte> header) => header.Length >= this.HeaderSize && this.IsRiffContainer(header) && this.IsWebpFile(header);
/// <summary>
/// Checks, if the header starts with a valid RIFF FourCC.
@ -30,6 +30,6 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// </summary>
/// <param name="header">The header bytes.</param>
/// <returns>True, if its a webp file.</returns>
private bool IsWebPFile(ReadOnlySpan<byte> header) => header.Slice(8, 4).SequenceEqual(WebpConstants.WebPHeader);
private bool IsWebpFile(ReadOnlySpan<byte> header) => header.Slice(8, 4).SequenceEqual(WebpConstants.WebpHeader);
}
}

2
src/ImageSharp/Formats/Webp/WebpMetadata.cs

@ -4,7 +4,7 @@
namespace SixLabors.ImageSharp.Formats.Webp
{
/// <summary>
/// Provides WebP specific metadata information for the image.
/// Provides Webp specific metadata information for the image.
/// </summary>
public class WebpMetadata : IDeepCloneable
{

40
tests/ImageSharp.Benchmarks/Codecs/DecodeWebp.cs

@ -26,10 +26,10 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
private string TestImageLosslessFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImageLossless);
[Params(TestImages.WebP.Lossy.Earth)]
[Params(TestImages.Webp.Lossy.Earth)]
public string TestImageLossy { get; set; }
[Params(TestImages.WebP.Lossless.Earth)]
[Params(TestImages.Webp.Lossless.Earth)]
public string TestImageLossless { get; set; }
[GlobalSetup]
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
[Benchmark(Description = "Magick Lossy Webp")]
public int WebpLossyMagick()
{
var settings = new MagickReadSettings { Format = MagickFormat.WebP };
var settings = new MagickReadSettings { Format = MagickFormat.Webp };
using var memoryStream = new MemoryStream(this.webpLossyBytes);
using var image = new MagickImage(memoryStream, settings);
return image.Width;
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
[Benchmark(Description = "Magick Lossless Webp")]
public int WebpLosslessMagick()
{
var settings = new MagickReadSettings { Format = MagickFormat.WebP };
var settings = new MagickReadSettings { Format = MagickFormat.Webp };
using var memoryStream = new MemoryStream(this.webpLossyBytes);
using var image = new MagickImage(memoryStream, settings);
return image.Width;
@ -88,22 +88,22 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
IterationCount=3 LaunchCount=1 WarmupCount=3
| Method | Job | Runtime | TestImageLossy | TestImageLossless | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|--------------------------- |----------- |-------------- |---------------------- |------------------------- |-----------:|----------:|---------:|----------:|----------:|------:|------------:|
| 'Magick Lossy Webp' | Job-IERNAB | .NET 4.7.2 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 105.8 ms | 6.28 ms | 0.34 ms | - | - | - | 17.65 KB |
| 'ImageSharp Lossy Webp' | Job-IERNAB | .NET 4.7.2 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 1,145.0 ms | 110.82 ms | 6.07 ms | - | - | - | 2779.53 KB |
| 'Magick Lossless Webp' | Job-IERNAB | .NET 4.7.2 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 145.9 ms | 8.55 ms | 0.47 ms | - | - | - | 18.05 KB |
| 'ImageSharp Lossless Webp' | Job-IERNAB | .NET 4.7.2 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 1,694.1 ms | 55.09 ms | 3.02 ms | 4000.0000 | 1000.0000 | - | 30556.87 KB |
| 'Magick Lossy Webp' | Job-IMRAGJ | .NET Core 2.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 105.7 ms | 1.89 ms | 0.10 ms | - | - | - | 15.75 KB |
| 'ImageSharp Lossy Webp' | Job-IMRAGJ | .NET Core 2.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 741.6 ms | 21.45 ms | 1.18 ms | - | - | - | 2767.85 KB |
| 'Magick Lossless Webp' | Job-IMRAGJ | .NET Core 2.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 146.1 ms | 9.52 ms | 0.52 ms | - | - | - | 16.54 KB |
| 'ImageSharp Lossless Webp' | Job-IMRAGJ | .NET Core 2.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 522.5 ms | 21.15 ms | 1.16 ms | 4000.0000 | 1000.0000 | - | 22860.02 KB |
| 'Magick Lossy Webp' | Job-NAASQX | .NET Core 3.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 105.9 ms | 5.34 ms | 0.29 ms | - | - | - | 15.45 KB |
| 'ImageSharp Lossy Webp' | Job-NAASQX | .NET Core 3.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 748.8 ms | 290.47 ms | 15.92 ms | - | - | - | 2767.84 KB |
| 'Magick Lossless Webp' | Job-NAASQX | .NET Core 3.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 146.1 ms | 1.14 ms | 0.06 ms | - | - | - | 15.9 KB |
| 'ImageSharp Lossless Webp' | Job-NAASQX | .NET Core 3.1 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 480.7 ms | 25.25 ms | 1.38 ms | 4000.0000 | 1000.0000 | - | 22859.7 KB |
| 'Magick Lossy Webp' | Job-GLNACU | .NET Core 5.0 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 105.7 ms | 4.71 ms | 0.26 ms | - | - | - | 15.48 KB |
| 'ImageSharp Lossy Webp' | Job-GLNACU | .NET Core 5.0 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 645.7 ms | 61.00 ms | 3.34 ms | - | - | - | 2768.13 KB |
| 'Magick Lossless Webp' | Job-GLNACU | .NET Core 5.0 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 146.5 ms | 18.63 ms | 1.02 ms | - | - | - | 15.8 KB |
| 'ImageSharp Lossless Webp' | Job-GLNACU | .NET Core 5.0 | WebP/earth_lossy.webp | WebP/earth_lossless.webp | 306.7 ms | 32.31 ms | 1.77 ms | 4000.0000 | 1000.0000 | - | 22860.02 KB |
| 'Magick Lossy Webp' | Job-IERNAB | .NET 4.7.2 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 105.8 ms | 6.28 ms | 0.34 ms | - | - | - | 17.65 KB |
| 'ImageSharp Lossy Webp' | Job-IERNAB | .NET 4.7.2 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 1,145.0 ms | 110.82 ms | 6.07 ms | - | - | - | 2779.53 KB |
| 'Magick Lossless Webp' | Job-IERNAB | .NET 4.7.2 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 145.9 ms | 8.55 ms | 0.47 ms | - | - | - | 18.05 KB |
| 'ImageSharp Lossless Webp' | Job-IERNAB | .NET 4.7.2 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 1,694.1 ms | 55.09 ms | 3.02 ms | 4000.0000 | 1000.0000 | - | 30556.87 KB |
| 'Magick Lossy Webp' | Job-IMRAGJ | .NET Core 2.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 105.7 ms | 1.89 ms | 0.10 ms | - | - | - | 15.75 KB |
| 'ImageSharp Lossy Webp' | Job-IMRAGJ | .NET Core 2.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 741.6 ms | 21.45 ms | 1.18 ms | - | - | - | 2767.85 KB |
| 'Magick Lossless Webp' | Job-IMRAGJ | .NET Core 2.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 146.1 ms | 9.52 ms | 0.52 ms | - | - | - | 16.54 KB |
| 'ImageSharp Lossless Webp' | Job-IMRAGJ | .NET Core 2.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 522.5 ms | 21.15 ms | 1.16 ms | 4000.0000 | 1000.0000 | - | 22860.02 KB |
| 'Magick Lossy Webp' | Job-NAASQX | .NET Core 3.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 105.9 ms | 5.34 ms | 0.29 ms | - | - | - | 15.45 KB |
| 'ImageSharp Lossy Webp' | Job-NAASQX | .NET Core 3.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 748.8 ms | 290.47 ms | 15.92 ms | - | - | - | 2767.84 KB |
| 'Magick Lossless Webp' | Job-NAASQX | .NET Core 3.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 146.1 ms | 1.14 ms | 0.06 ms | - | - | - | 15.9 KB |
| 'ImageSharp Lossless Webp' | Job-NAASQX | .NET Core 3.1 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 480.7 ms | 25.25 ms | 1.38 ms | 4000.0000 | 1000.0000 | - | 22859.7 KB |
| 'Magick Lossy Webp' | Job-GLNACU | .NET Core 5.0 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 105.7 ms | 4.71 ms | 0.26 ms | - | - | - | 15.48 KB |
| 'ImageSharp Lossy Webp' | Job-GLNACU | .NET Core 5.0 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 645.7 ms | 61.00 ms | 3.34 ms | - | - | - | 2768.13 KB |
| 'Magick Lossless Webp' | Job-GLNACU | .NET Core 5.0 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 146.5 ms | 18.63 ms | 1.02 ms | - | - | - | 15.8 KB |
| 'ImageSharp Lossless Webp' | Job-GLNACU | .NET Core 5.0 | Webp/earth_lossy.webp | Webp/earth_lossless.webp | 306.7 ms | 32.31 ms | 1.77 ms | 4000.0000 | 1000.0000 | - | 22860.02 KB |
*/
}
}

8
tests/ImageSharp.Benchmarks/Codecs/EncodeWebp.cs

@ -44,8 +44,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public void MagickWebpLossy()
{
using var memoryStream = new MemoryStream();
this.webpMagick.Settings.SetDefine(MagickFormat.WebP, "lossless", false);
this.webpMagick.Write(memoryStream, MagickFormat.WebP);
this.webpMagick.Settings.SetDefine(MagickFormat.Webp, "lossless", false);
this.webpMagick.Write(memoryStream, MagickFormat.Webp);
}
[Benchmark(Description = "ImageSharp Webp Lossy")]
@ -62,8 +62,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public void MagickWebpLossless()
{
using var memoryStream = new MemoryStream();
this.webpMagick.Settings.SetDefine(MagickFormat.WebP, "lossless", true);
this.webpMagick.Write(memoryStream, MagickFormat.WebP);
this.webpMagick.Settings.SetDefine(MagickFormat.Webp, "lossless", true);
this.webpMagick.Write(memoryStream, MagickFormat.Webp);
}
[Benchmark(Description = "ImageSharp Webp Lossless")]

4
tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs

@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
};
// Convert image pixels to bgra array.
byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.WebP.Peak));
byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.Webp.Peak));
using var image = Image.Load<Rgba32>(imgBytes);
uint[] bgra = ToBgra(image);
@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
};
// Convert image pixels to bgra array.
byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.WebP.Lossless.BikeSmall));
byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.Webp.Lossless.BikeSmall));
using var image = Image.Load<Rgba32>(imgBytes, new WebpDecoder());
uint[] bgra = ToBgra(image);

2
tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs

@ -6,7 +6,7 @@ using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit;
using static SixLabors.ImageSharp.Tests.TestImages.WebP;
using static SixLabors.ImageSharp.Tests.TestImages.Webp;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Webp

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

@ -6,7 +6,7 @@ using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit;
using static SixLabors.ImageSharp.Tests.TestImages.WebP;
using static SixLabors.ImageSharp.Tests.TestImages.Webp;
namespace SixLabors.ImageSharp.Tests.Formats.Webp
{

20
tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs

@ -16,10 +16,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
private static WebpDecoder WebpDecoder => new WebpDecoder() { IgnoreMetadata = false };
[Theory]
[WithFile(TestImages.WebP.Lossy.WithExif, PixelTypes.Rgba32, false)]
[WithFile(TestImages.WebP.Lossy.WithExif, PixelTypes.Rgba32, true)]
[WithFile(TestImages.WebP.Lossless.WithExif, PixelTypes.Rgba32, false)]
[WithFile(TestImages.WebP.Lossless.WithExif, PixelTypes.Rgba32, true)]
[WithFile(TestImages.Webp.Lossy.WithExif, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Webp.Lossy.WithExif, PixelTypes.Rgba32, true)]
[WithFile(TestImages.Webp.Lossless.WithExif, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Webp.Lossless.WithExif, PixelTypes.Rgba32, true)]
public void IgnoreMetadata_ControlsWhetherExifIsParsed<TPixel>(TestImageProvider<TPixel> provider, bool ignoreMetadata)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -42,10 +42,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
}
[Theory]
[WithFile(TestImages.WebP.Lossy.WithIccp, PixelTypes.Rgba32, false)]
[WithFile(TestImages.WebP.Lossy.WithIccp, PixelTypes.Rgba32, true)]
[WithFile(TestImages.WebP.Lossless.WithIccp, PixelTypes.Rgba32, false)]
[WithFile(TestImages.WebP.Lossless.WithIccp, PixelTypes.Rgba32, true)]
[WithFile(TestImages.Webp.Lossy.WithIccp, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Webp.Lossy.WithIccp, PixelTypes.Rgba32, true)]
[WithFile(TestImages.Webp.Lossless.WithIccp, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Webp.Lossless.WithIccp, PixelTypes.Rgba32, true)]
public void IgnoreMetadata_ControlsWhetherIccpIsParsed<TPixel>(TestImageProvider<TPixel> provider, bool ignoreMetadata)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
}
[Theory]
[WithFile(TestImages.WebP.Lossy.WithExif, PixelTypes.Rgba32)]
[WithFile(TestImages.Webp.Lossy.WithExif, PixelTypes.Rgba32)]
public void EncodeLossyWebp_PreservesExif<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
}
[Theory]
[WithFile(TestImages.WebP.Lossless.WithExif, PixelTypes.Rgba32)]
[WithFile(TestImages.Webp.Lossless.WithExif, PixelTypes.Rgba32)]
public void EncodeLosslessWebp_PreservesExif<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

2
tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
public class YuvConversionTests
{
[Theory]
[WithFile(TestImages.WebP.Yuv, PixelTypes.Rgba32)]
[WithFile(TestImages.Webp.Yuv, PixelTypes.Rgba32)]
public void ConvertRgbToYuv_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

2
tests/ImageSharp.Tests/TestImages.cs

@ -517,7 +517,7 @@ namespace SixLabors.ImageSharp.Tests
public const string NoAlphaBits32BitRle = "Tga/32bit_rle_no_alphabits.tga";
}
public static class WebP
public static class Webp
{
// Reference image as png
public const string Peak = "Webp/peak.png";

Loading…
Cancel
Save