Table of Contents

Class WebPEncoder

Namespace
Imazen.WebP
Assembly
Imazen.WebP.dll

Raw buffer WebP encoder. No System.Drawing dependency — works on all platforms.

public static class WebPEncoder
Inheritance
WebPEncoder
Inherited Members

Methods

Encode(byte[], int, int, int, WebPPixelFormat, WebPEncoderConfig)

Encodes raw pixel data using advanced WebPEncoderConfig settings. Uses the full WebPPicture/WebPConfig pipeline for maximum control.

public static byte[] Encode(byte[] pixels, int width, int height, int stride, WebPPixelFormat format, WebPEncoderConfig config)

Parameters

pixels byte[]

Raw pixel data

width int

Image width in pixels

height int

Image height in pixels

stride int

Byte stride (bytes per row)

format WebPPixelFormat

Pixel format of the input data

config WebPEncoderConfig

Advanced encoder configuration

Returns

byte[]

Encoded WebP data

Encode(byte[], int, int, int, WebPPixelFormat, WebPEncoderConfig, Stream)

Encodes raw pixel data using advanced WebPEncoderConfig settings and writes to a stream.

public static void Encode(byte[] pixels, int width, int height, int stride, WebPPixelFormat format, WebPEncoderConfig config, Stream outputStream)

Parameters

pixels byte[]
width int
height int
stride int
format WebPPixelFormat
config WebPEncoderConfig
outputStream Stream

Encode(byte[], int, int, int, WebPPixelFormat, float)

Encodes raw pixel data to WebP format. Returns the encoded bytes.

public static byte[] Encode(byte[] pixels, int width, int height, int stride, WebPPixelFormat format, float quality)

Parameters

pixels byte[]

Raw pixel data

width int

Image width in pixels

height int

Image height in pixels

stride int

Byte stride (bytes per row)

format WebPPixelFormat

Pixel format of the input data

quality float

0-100 for lossy, -1 for lossless

Returns

byte[]

Encoded WebP data

Encode(byte[], int, int, int, WebPPixelFormat, float, Stream)

Encodes raw pixel data to WebP format and writes to a stream.

public static void Encode(byte[] pixels, int width, int height, int stride, WebPPixelFormat format, float quality, Stream output)

Parameters

pixels byte[]
width int
height int
stride int
format WebPPixelFormat
quality float
output Stream