libwebp

This is a binding to the libwebp library.

Usage

Preparation

```toml

Cargo.toml

[dependencies] libwebp = { version = "0.1.2", features = ["0_6"] } ```

Simple decoding

```rust use libwebp::WebPDecodeRGBA;

let data: &[u8];

let (width, height, buf) = WebPDecodeRGBA(data).unwrap(); eprintln!("width = {}, height = {}", width, height); eprintln!( "top-left pixel: rgba({}, {}, {}, {})", buf[0], buf[1], buf[2], buf[3] as f64 / 255.0, ) ```

Simple encoding

```rust use libwebp::WebPEncodeRGBA;

let buf: &[u8] = &[ 255, 255, 255, 255, // white 255, 0, 0, 255, // red 0, 255, 0, 255, // green 0, 0, 255, 255, // blue ]; let data = WebPEncodeRGBA(buf, 2, 2, 8, 75.0).unwrap(); let lossless_data = WebPEncodeLosslessRGBA(buf, 2, 2, 8).unwrap(); ```

Minimum Supported Rust Version (MSRV)

Rust 1.31.0

Features

Linking

If libwebp is found in the system, it links against the library. Otherwise it builds and links against the bundled libwebp.

In these cases, static link is preferred:

Related repositories

Completeness