Table of Contents

Class WebpWriterOptions

Namespace
Egami.Formats.Webp
Assembly
Egami.dll

Options for writing WebP. The defaults follow libwebp's: quality 75 and effort (libwebp's method) 4. A raster read from a WebP file keeps its kind, lossless or lossy; anything else is written lossy.

public sealed class WebpWriterOptions : WriterOptions
Inheritance
WebpWriterOptions
Inherited Members

Examples

// Lossy, the default for rasters not read from WebP: quality 0 to 100 and effort 0 to 6 on cwebp's scales.
photo.Save("small.webp", new WebpWriterOptions { Quality = 80 });

// Lossless: every pixel exact, colors under full transparency included. Effort 0 (fastest) to 6 (smallest).
photo.Save("duck.webp", new WebpWriterOptions { Lossless = true, Effort = 6 });

// A raster read from a WebP file keeps its kind when saved with the defaults.
using Raster again = Raster.Load("duck.webp");
again.Save("copy.webp");

Properties

AlphaQuality

Gets the alpha quality of lossy files with transparency, 0 to 100: 100 stores alpha losslessly; lower values reduce the number of alpha levels first. Defaults to 100.

public int AlphaQuality { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 100.

Default

Gets the default options.

public static WebpWriterOptions Default { get; }

Property Value

WebpWriterOptions

Effort

Gets how hard the encoder works, 0 (fastest) to 6 (smallest files), on libwebp's method scale, for both kinds. Defaults to 4.

public int Effort { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 6.

FirstFrameOnly

Gets whether to write only the first frame, as a still image. Defaults to false.

public bool FirstFrameOnly { get; init; }

Property Value

bool

KeepTransparentColors

Gets whether the colors of fully transparent pixels are kept: exactly in lossless data, so every pixel round-trips, and as closely as the quality allows in lossy data. Defaults to true; false lets either encoder change those colors for smaller files (lossy flattens them), as libwebp does unless told to stay exact.

public bool KeepTransparentColors { get; init; }

Property Value

bool

Lossless

Gets whether to write lossless (VP8L, every pixel exact) or lossy (VP8) data, or null (the default) to keep the kind of the WebP file the raster was read from (Lossless), and write lossy otherwise.

public bool? Lossless { get; init; }

Property Value

bool?

MixedFrames

Gets whether each frame of an animation is encoded both lossless and lossy and the smaller kept, as libwebp's img2webp -mixed does. About twice the encode time. Defaults to false.

public bool MixedFrames { get; init; }

Property Value

bool

NearLossless

Gets the near-lossless level for lossless data, 0 to 100 on libwebp's scale: below 100 the encoder may move pixel values a little before coding them, for smaller files that are no longer exact. Defaults to 100 (exact).

public int NearLossless { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 100.

Quality

Gets the lossy quality, 0 (smallest) to 100 (best), on libwebp's scale, so the same number gives about the same file as cwebp -q. Ignored for lossless data. Defaults to 75.

public int Quality { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 100.

SharpYuv

Gets whether lossy data uses a slower RGB to YUV conversion that keeps sharp colored edges, libwebp's sharp YUV. Defaults to false.

public bool SharpYuv { get; init; }

Property Value

bool