Pillow's WebP method argument trades CPU for bytes, and the default of 4 is a fair middle. On a 1920 × 1076 photo at quality 80, method=6 wrote 101,962 bytes, 4.6% less than the default 106,836, and took 195 ms instead of 135 ms. method=0 was fastest at 34 ms but wrote 130,560 bytes, 22.2% more. The image quality score was nearly flat across all seven levels.
What does method control?
The Pillow WebP docs describe it as a quality/speed trade-off, "0=fast, 6=slower-better", defaulting to 4. It does not change the quality number you pass. In effect it sets how much effort the encoder spends at that quality: the same quality target, more effort, fewer bytes. I only timed the encode. I did not time decoding.
The script
It encodes one photo at quality 80 for every method, times each encode and scores the decoded result against the source with PSNR.
The first line saves without a method argument. It matched method 4 byte for byte (106,836 B), which confirms the documented default.
PSNR (peak signal-to-noise ratio) is a rough number: higher means closer to the source,. It does not replace looking at the image. Timing uses time.process_time() (CPU time), median of 5, encode only.
What did it print?
Where is the sweet spot?
- Method 0 to 1 save time and cost bytes. Method 0 took 33.9 ms and wrote 22.2% more than the default. Method 1 took 42.3 ms and wrote 14.1% more. Use these only when encode time is the real limit.
- Method 2 is cheap and close. It took 59.1 ms and wrote 3.4% more than the default. That is less than half the time of method 4 for a small byte cost.
- Methods 3 and 4 were the same here. Method 3 wrote 106,638 bytes in 136.7 ms. Method 4 wrote 106,836 bytes in 135.0 ms. A 198 byte gap on one photo is noise, so do not read it as a rule.
- Method 5 and 6 pay for bytes with time. Method 5 saved 2.0% for about the same time as method 4 (137.7 ms). Method 6 saved 4.6% but cost about 45% more CPU than the default (195.1 ms against 135.0 ms).
Method 5 stands out: in this run it was nearly free. It took 2.7 ms longer than method 4 and saved 2,154 bytes. I would test it on my own photos before trusting that, since encoder time can swing with image content.
Note: PSNR stayed between 38.46 dB and 38.67 dB for all seven methods. The ranking by bytes is not a ranking by quality, and method 6 had the lowest PSNR (38.46 dB) of the lot, 0.19 dB under the default. If you chase the smallest file, check the picture too.
How big is the method effect next to quality?
Smaller than a few quality steps. The whole method range, 0 to 6, spans 28,598 bytes (130,560 down to 101,962). I also encoded the same photo at method=0 and raised quality from 80 to 85. That added 40,468 bytes (130,560 to 171,028) and lifted PSNR from 38.53 dB to 39.65 dB. So quality moves both size and score. Method moves size and leaves the score almost where it was. That makes method the safer knob when you cannot afford to change how the picture looks, and quality the knob to use when you can.
Which method should you use?
For a request-time encode, where a user waits, use method 2 or the default. For a build step or a queue worker that runs once per image and serves it a million times, use method 6. A 4.6% saving on a 106,836 byte file is 4,874 bytes per view, and the CPU is spent once.
im.save("photo.webp", "WEBP", quality=80, method=6)
If you would rather not manage encoder settings, the JPG to WebP converter converts without any code, and the WebP explainer covers what the format can and cannot do.
How I measured
- Machine: Apple M1 Pro, macOS, 2026-10-18.
- Python 3.9.6 in a fresh venv, Pillow 11.3.0 with libwebp 1.5.0 (from
PIL.features). - Input:
image-compressor-sample-camera-photo.jpeg(4964 × 2782) resized to 1920 × 1076 with LANCZOS. - Times: CPU time, median of 5 encodes. The machine was busy with other jobs, so I did not use the wall clock.
- PSNR: decoded WebP against the 1920 × 1076 RGB source, computed with NumPy.
- Bytes are exact and repeat from run to run. The times will differ on your machine.
What I did not test
Other photos, other quality values, lossless WebP, images with alpha, and what the output looks like at 100% zoom.
I build Blinkimg, an image compressor and converter with a developer API. I wrote this article with help from an AI assistant (Claude), which ran the code on my machine; every number in it comes from those runs.

Top comments (0)