imazen / imazen/zenwebp

Encoder: brute-force config search per-image (zenjpeg/coefficient pattern)

Open
#39 0 comments 0 reactions 1 assignee View on GitHub

@lilith is already working on this.

Since Apr 26, 2026.

enhancement
Dominant language
Rust
Stars
15
Forks
1
PR merge metrics
No merged PRs in 30d

Description

**Future work** — discussed during the libwebp-parity sprint (audit branch `audit/libwebp-parity-2026-04-26`).

## What

Add a "config search" mode to the encoder, modeled after the brute-force / Pareto-search pass that `coefficient` and `zenjpeg` already do. For each input image, the encoder probes multiple (preset, sns_strength, filter_strength, segments, partition_limit, cost_model, ...) tuples and picks the one that wins on the user-chosen objective (smallest size at target quality, best butteraugli at target size, etc.).

## Why

Even with good defaults, individual images respond differently to perceptual tuning (e.g., gradients vs. text-heavy graphics vs. photos). A per-image search routinely produces ~5–10% better RD curves on `zenjpeg`'s benchmark corpus.

## Sketch

- New API: `EncoderConfig::with_search(SearchObjective::MinSize { target_quality }, max_probes: 16)`.
- Internal probe loop: encodes the image at each candidate config, decodes for quality (zensim / fast-ssim2 / butteraugli), records (size, quality), filters by objective, returns the best.
- Pareto-frontier extraction so the user can pick along the curve.
- Honors `CostModel` selection: if user picks `StrictLibwebpParity`, only libwebp-equivalent configs are probed.
- Caches per-image features (DCT histogram, edge density, color count) so the probe set can be pruned heuristically (e.g. low-color images skip Photo preset).

## References

- `coefficient` crate's per-codec config sweep loop (in `~/work/coefficient/`)
- `zenjpeg`'s adaptive-quantization pre-pass

## Dependencies

- Bit-exact libwebp parity mode (issue tracking the StrictLibwebpParity north star) — needed as the comparison reference and as one of the candidate configs.
- A solid `parity_baseline`-style harness for size+quality+speed measurement (`dev/parity_baseline.rs` already exists).

## Status

Backlog. No implementation in this session.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.