|
|
@ -4,9 +4,11 @@ |
|
|
using System.IO; |
|
|
using System.IO; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using SixLabors.ImageSharp.Advanced; |
|
|
using SixLabors.ImageSharp.Advanced; |
|
|
|
|
|
using SixLabors.ImageSharp.Formats.Bmp; |
|
|
using SixLabors.ImageSharp.Formats.Webp.Lossless; |
|
|
using SixLabors.ImageSharp.Formats.Webp.Lossless; |
|
|
using SixLabors.ImageSharp.Formats.Webp.Lossy; |
|
|
using SixLabors.ImageSharp.Formats.Webp.Lossy; |
|
|
using SixLabors.ImageSharp.Memory; |
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
|
|
using SixLabors.ImageSharp.Metadata; |
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Formats.Webp |
|
|
namespace SixLabors.ImageSharp.Formats.Webp |
|
|
@ -27,11 +29,6 @@ namespace SixLabors.ImageSharp.Formats.Webp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly bool alphaCompression; |
|
|
private readonly bool alphaCompression; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Indicating whether lossy compression should be used. If false, lossless compression will be used.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly bool lossy; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Compression quality. Between 0 and 100.
|
|
|
/// Compression quality. Between 0 and 100.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -73,6 +70,11 @@ namespace SixLabors.ImageSharp.Formats.Webp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly int nearLosslessQuality; |
|
|
private readonly int nearLosslessQuality; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Indicating whether lossy compression should be used. If false, lossless compression will be used.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private bool? lossy; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The global configuration.
|
|
|
/// The global configuration.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -112,8 +114,11 @@ namespace SixLabors.ImageSharp.Formats.Webp |
|
|
Guard.NotNull(stream, nameof(stream)); |
|
|
Guard.NotNull(stream, nameof(stream)); |
|
|
|
|
|
|
|
|
this.configuration = image.GetConfiguration(); |
|
|
this.configuration = image.GetConfiguration(); |
|
|
|
|
|
ImageMetadata metadata = image.Metadata; |
|
|
|
|
|
WebpMetadata webpMetadata = metadata.GetWebpMetadata(); |
|
|
|
|
|
this.lossy ??= webpMetadata.Format == WebpFormatType.Lossy; |
|
|
|
|
|
|
|
|
if (this.lossy) |
|
|
if (this.lossy.GetValueOrDefault()) |
|
|
{ |
|
|
{ |
|
|
using var enc = new Vp8Encoder( |
|
|
using var enc = new Vp8Encoder( |
|
|
this.memoryAllocator, |
|
|
this.memoryAllocator, |
|
|
|