WebP encoder method — what the speed/size dial actually does
The WebP encoder takes a quality slider (0–100) like JPEG, but it has a second knob that JPEG doesn't have: a method selector from 0 to 6. Method is independent of quality. It controls how hard the encoder works to find the smallest representation of a given quality target — slower methods explore more options and pick smaller ones.
Our pipeline exposes this as an "optimisation level" 0–3 that maps to method 1–4 plus a pass count. This article walks through what's actually different between those settings and when each one is the right choice.
What method tunes inside the encoder
WebP's lossy encoder makes a series of choices for each block of the image:
- Predictor. Each block's pixels are predicted from neighbouring blocks (above, left, top-left). The encoder picks one of several predictor modes per block. Higher methods search more candidate predictors.
- Transform block size. Like JPEG's 8 × 8, but WebP supports 4 × 4 and 16 × 16 too. Smaller blocks adapt to detail; larger blocks compress flat regions better. Higher methods consider all sizes; lower methods just use the default.
- In-loop deblocking filter. WebP smooths block boundaries during encoding to reduce blocking artefacts. Filter strength is variable; higher methods pick per-segment.
- Segmentation. The image is split into up to 4 segments, each with its own quantization parameters. Higher methods analyse content to choose segment boundaries optimally.
- Entropy coding mode. WebP can pick different probability contexts for different macroblocks. Higher methods explore more.
Method 0 makes the simplest choice for each. Method 6 exhaustively searches. The size difference between methods 0 and 6 is typically 5–8% on photographic content, and the time difference is roughly 7–10×.
Our mapping from optimisation level to method
The pipeline exposes four optimisation levels:
level 0 → method = 1, pass = 1 (fastest)
level 1 → method = 2, pass = 1
level 2 → method = 3, pass = 1 (default)
level 3 → method = 4, pass = 2 (slowest, smallest)
We don't go above method 4 or below method 1. Method 0 is rarely useful (the speed gain over 1 is small; the size cost is real), and methods 5–6 trade encoding time at a worse rate than is worth on a browser-side pipeline.
The pass count
WebP supports running the analysis pass twice for slightly better results. The first pass collects statistics about the image; the second pass uses them to make better decisions. We enable two-pass only at the highest optimisation level — it doubles encode time and saves about 1%.
For typical photo workflow, pass = 1 is enough. The encoder's per-block decisions are good even on a single look at the image. Pass = 2 is for archive workflows where the file will be served millions of times and 1% matters.
Quality and method are independent
You can set quality 80 with method 1, or quality 80 with method 4. Both produce visually equivalent images at quality 80. The difference is purely how big the file is and how long encoding took.
This is different from JPEG, where quality is the only knob. WebP gives you two: quality controls the perceptual fidelity target, method controls how efficiently the encoder reaches that target.
What to pick for what use case
- Real-time UI feedback (preview) — level 0 (method 1, pass 1). Encodes in well under a second on a modern phone.
- Default download — level 2 (method 3, pass 1). About 2× slower than baseline, ~6% smaller. Sub-second on most photos at typical resolutions.
- "Maximum compression" — level 3 (method 4, pass 2). 3–4× slower than baseline, ~9% smaller. Useful when bandwidth costs matter or files are served many times.
- Animated WebP — currently uses a separate code path that processes all frames at the chosen quality and reassembles them. Method tuning has less impact there because each frame is small.
Other knobs we hold fixed
The WebP encoder exposes about thirty parameters. Most of them shouldn't be touched in a general-purpose tool. The ones we set to fixed reasonable values:
- 4:2:0 chroma subsampling — same as JPEG's default.
- Alpha quality 100 — alpha channel is encoded losslessly. Lossy alpha visibly damages soft-edged shapes.
- SNS strength 50 — spatial noise shaping at moderate strength, the encoder's default.
- Filter strength 60, sharpness 0 — moderate deblocking, no edge sharpening.
- 4 segments — full content-adaptive segmentation. Disabling this would reduce encode time slightly but cost size on heterogeneous content.
The rest of the parameters live in the file specification and rarely warrant attention from anyone but encoder researchers.