Overview
High-performance image compression in Rust: a library, a CLI, and a
self-hostable HTTP server (PoC). JPEG, PNG, WebP — and AVIF with the
avif feature — in and out, plus GIF in (animated GIF included, as
animated WebP); sources are format-sniffed by magic bytes and re-encoded
in their own format (GIF, having no encoder here, becomes WebP). On
imgproxy’s official benchmark harness, run on
the same AWS instance types as their published results (2026-10),
0.15.0 does 1.24-1.33x imgproxy 4.0.17’s JPEG req/s on c7i.large
(across two instances) and 1.51-1.53x on c7g.large, while resizing in linear
light at measurably higher output quality. Single runs of the other
formats put it ahead on PNG and WebP on both and on AVIF on Graviton,
and level on AVIF on x86-64 (see Benchmarks).
- HTTP resize service:
GET /resize/{w}/{h}/{file}fits the source withinw x h(never enlarges) and re-encodes it in its own format.0leaves an axis unconstrained (/resize/750/0/…is width-only — whatsrcsetwdescriptors and Next.js loaders emit), and{file}may span directories, so S3-style prefixes and nested trees are addressable as-is. Optional imgproxy-style HMAC URL signing. - Cloudflare Images URL compatibility: mount a second route
(
OXIMG_OPTIONS_PREFIX) speaking the option-list grammar —/image/width=750,quality=80/path/to/photo.png— so URLs built for Cloudflare Images survive a migration without a rewrite layer, per-request quality included. - Sources: a local directory, any HTTP(S) origin, a private
GCS bucket (
gs://with GCP-attached credentials — no public bucket, no public-endpoint egress), or a private S3 or S3-compatible bucket (s3://with static keys: AWS S3, R2, MinIO). The origin round trip never holds a CPU slot (fetches are buffered and separately bounded), and transient fetch failures are retried, so a network blip is a slower response, not a broken image. - Production operability: graceful SIGTERM drain, upstream fetch
deadlines (slow-origin 504s distinct from broken-origin 502s), and
an opt-in Prometheus
/metricspage whose queue-wait/processing split tells “needs more CPU” apart from “sources got bigger”. - Quality-first processing: resizing happens in linear light on
16-bit samples with Lanczos3, JPEG sources are decoded at full size
so the whole reduction is the resampler’s, and alpha is premultiplied
across the resample — the properties behind the SSIMULACRA2 scores in
Benchmarks. The one exception is a reduction large
enough that a half-size decode of a 4:2:0 source still leaves 1.9x
for the resampler.
There luma decodes at 1/2 through a linear-light 2x2 average of the
full IDCT (
OXIMG_LINEAR_SHRINK). That costs 0.3 SSIMULACRA2 at 4x and nothing measurable from 5.3x up, where libjpeg’s own 1/2 costs 2.7. libjpeg’s shrink-on-load (OXIMG_DCT_MARGIN) is available and off by default: it buys decode time with quality. Against a lossless ground truth (100 DIV2K photographs, linear-light reference), full decode scores best at every ratio from 2x to 14x, and the 3/8 scale the old default picked at 5.3x costs 6.4 SSIMULACRA2 points on average, for the same output size and the same bytes. - Performance as architecture, not flags: per-arch row-streaming SIMD resize kernels (AVX2 on x86-64, NEON on aarch64, both verified against an f64 reference), JPEG decode fused with resize+encode on a second thread under low load, request coalescing for concurrent identical URLs (per-process — a horizontally scaled deployment gets its dedup from the CDN in front, not from here), and CPU concurrency pinned to the core count. Peak memory stays at a fraction of imgproxy’s under identical load (BENCH.md).
- Tunable profiles: the default maximizes quality per byte
(progressive jpegli, sequential for thumbnails up to 12k pixels);
one env flip (
OXIMG_JPEG_PROGRESSIVE=0) trades 2-3% output size on photos (up to ~11% on graphics) for 5-28% less server CPU, at unchanged pixels.PRESET=fast|smallselects mozjpeg profiles instead. - Self-contained deploys: multi-arch Docker images
(linux/amd64 + linux/arm64) on Docker Hub (
oximg/oximg) and GHCR (ghcr.io/oximg/oximg); a single static-leaning binary otherwise.