Menu

WebP effort in sharp: size and time for levels 0 to 6
📰

WebP effort in sharp: size and time for levels 0 to 6

DEV Community: node·Sahadat Husain·18 days ago
#r1bTvioX
#devtonodejs#devto#dev#effort#psnr
Long article (1273 words) — no AI summary yet.
Reading 0:00
15s threshold

Effort 2 is the step worth taking for WebP in sharp. On a 1920 × 1076 photo at quality 80, effort 0 wrote 130.9 KB in 34 ms. Effort 2 wrote 110.4 KB in 60 ms, which is 15.6% smaller for 26 ms more. Effort 6 wrote 102.3 KB but took 214 ms. The default, effort 4, sits in the middle at 106.9 KB and 141 ms.

Here is the script, what it printed, and how the curve changes for screenshots and lossless files.

What does effort do in sharp's webp()?

The effort option is CPU effort, from 0 (fastest) to 6 (slowest), with a default of 4. The sharp output docs say that and little more. In plain terms, it sets how many encoding tools the encoder tries before it settles.

Effort does not change quality . At a fixed quality, a higher effort should give a smaller file of about the same picture. The next sections test that claim.

How do you time WebP effort levels?

Decode and resize once, keep the raw pixels, then time only the encode.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.