Class WebpEncoder
Image encoder for writing an image to a stream in the Webp format.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp.Formats.Webp
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class WebpEncoder : ImageEncoder, IImageEncoder
Properties
| Edit this page View SourceEntropyPasses
Gets the number of entropy-analysis passes (in [1..10]). Defaults to 1.
Declaration
public int EntropyPasses { get; init; }
Property Value
Type | Description |
---|---|
int |
FileFormat
Gets the webp file format used. Either lossless or lossy. Defaults to lossy.
Declaration
public WebpFileFormatType? FileFormat { get; init; }
Property Value
Type | Description |
---|---|
WebpFileFormatType? |
FilterStrength
Gets the strength of the deblocking filter, between 0 (no filtering) and 100 (maximum filtering). A value of 0 will turn off any filtering. Higher value will increase the strength of the filtering process applied after decoding the picture. The higher the value the smoother the picture will appear. Typical values are usually in the range of 20 to 50. Defaults to 60.
Declaration
public int FilterStrength { get; init; }
Property Value
Type | Description |
---|---|
int |
Method
Gets the encoding method to use. Its a quality/speed trade-off (0=fast, 6=slower-better). Defaults to 4.
Declaration
public WebpEncodingMethod Method { get; init; }
Property Value
Type | Description |
---|---|
WebpEncodingMethod |
NearLossless
Gets a value indicating whether near lossless mode should be used. This option adjusts pixel values to help compressibility, but has minimal impact on the visual quality.
Declaration
public bool NearLossless { get; init; }
Property Value
Type | Description |
---|---|
bool |
NearLosslessQuality
Gets the quality of near-lossless image preprocessing. The range is 0 (maximum preprocessing) to 100 (no preprocessing, the default). The typical value is around 60. Note that lossy with -q 100 can at times yield better results.
Declaration
public int NearLosslessQuality { get; init; }
Property Value
Type | Description |
---|---|
int |
Quality
Gets the compression quality. Between 0 and 100. For lossy, 0 gives the smallest size and 100 the largest. For lossless, this parameter is the amount of effort put into the compression: 0 is the fastest but gives larger files compared to the slowest, but best, 100. Defaults to 75.
Declaration
public int Quality { get; init; }
Property Value
Type | Description |
---|---|
int |
SpatialNoiseShaping
Gets the amplitude of the spatial noise shaping. Spatial noise shaping (or sns for short) refers to a general collection of built-in algorithms used to decide which area of the picture should use relatively less bits, and where else to better transfer these bits. The possible range goes from 0 (algorithm is off) to 100 (the maximal effect). Defaults to 50.
Declaration
public int SpatialNoiseShaping { get; init; }
Property Value
Type | Description |
---|---|
int |
TransparentColorMode
Gets a value indicating whether to preserve the exact RGB values under transparent area. Otherwise, discard this invisible RGB information for better compression. The default value is Clear.
Declaration
public WebpTransparentColorMode TransparentColorMode { get; init; }
Property Value
Type | Description |
---|---|
WebpTransparentColorMode |
UseAlphaCompression
Gets a value indicating whether the alpha plane should be compressed with Webp lossless format. Defaults to true.
Declaration
public bool UseAlphaCompression { get; init; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceEncode<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | image | The Image<TPixel> to encode from. |
Stream | stream | The Stream to encode the image data to. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Overrides
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.