Skip to content

Rust library

The oximg::pipeline module is usable without the HTTP server — process/process_path take a Params and return the re-encoded bytes plus their format, probe reads just the header, and probe_animation reports frame count, play time and loop count for an animated source (GIF and WebP) without decoding pixels. Depend on it with default-features = false to drop the entire HTTP stack (axum, tokio, reqwest, hmac, sha2, serde_json); add features = ["avif"] for AVIF. The remote-source functions need the server feature: fetch_url/fetch_gcs download a bounded buffer (with _async variants for callers already inside a runtime), and process_url/process_gcs are fetch-then-decode in one call.

Failures are typed: every entry point returns pipeline::Error, whose kind() (ErrorKind: SourceNotFound / SourceTooLarge / SourceUnreadable / Upstream / UpstreamTimeout / Undecodable / Internal) is the stable classification the server’s own status mapping is built on — match on it instead of parsing messages, with a wildcard arm for kinds added later. Params also carries per-call overrides (webp_quality, png_effort, png_quantize, auto_rotate, icc, flatten_bg, linear_light, avif_quality, …) for the knobs that are otherwise process-global environment variables: None keeps the env-configured behavior, Some wins per call — so one process can run different settings side by side. Rustdoc examples on probe, process, and Params are compiled and run in CI; see also examples/:

Terminal window
cargo run --release --example thumbnail -- photo.jpg 300 200 out.jpg
cargo run --release --example transcode -- photo.jpg 800 800 webp out.webp
cargo run --release --example probe -- photo.webp