fast_webp/lib.rs
1//! Fast WebP encoding for the two common Rust workflows:
2//!
3//! - `image` crate buffers (`DynamicImage`, `RgbImage`, `RgbaImage`) to WebP.
4//! - JPEG/PNG bytes from servers and proxies to WebP bytes.
5//!
6//! The low-level hot path is intentionally small:
7//! RGB/RGBA bytes are validated and passed directly to `libwebp-sys`.
8//!
9//! ```rust
10//! use fast_webp::{encode_rgb, WebpOptions};
11//!
12//! let rgb = [255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255];
13//! let webp = encode_rgb(&rgb, 2, 2, WebpOptions::default())?;
14//! # Ok::<(), fast_webp::WebpError>(())
15//! ```
16
17mod bytes;
18mod encode;
19mod error;
20mod options;
21mod pixel;
22
23#[cfg(feature = "image")]
24mod image_api;
25
26pub use bytes::{convert_bytes_to_webp, detect_format, InputFormat};
27pub use encode::{encode_rgb, encode_rgba};
28pub use error::WebpError;
29pub use options::WebpOptions;
30
31#[cfg(feature = "image")]
32pub use image_api::{encode_dynamic_image, encode_rgb_image, encode_rgba_image};
33
34#[cfg(test)]
35mod tests;