WEBP is awesome

⏱ to read: 15 mins

I have long ignored the presence of WEBP format. Yeah, sure, it would be good to have site images 10% or 20% smaller… – I thought. Considering WEBP had abysmal browser support back then, I didn’t even bother to check it in more details. Boy, was I surprised yesterday!

It was hard to believe when I first saw the numbers. There should be a mistake – I thought. You can’t really take a compressed file like JPG or PNG and compress it several times more without a huge quality drop. Or can you?

I performed a small suit of tests and the results are below in all their glory. The wins aren’t like 20% or even 30%. They are more like 80% to 90%, whatever it means.

As many others, I thought of WEBP as of a strictly lossless format. In fact, it can be lossy or lossless just like JPG or PNG. The below tests are taken with webp-converter.com at 50, 75, 90, 95 and 99 leves if IQ (image quality). The original is JPG or PNG at 100% IQ. Which, of course, is still a compressed image data.

Texture

Let’s start with the texture we use in the current site design.

Quality 99%

original
no visual difference
166Kb → 62Kb

Quality 95%

original
no visual difference
166Kb → 45Kb

Quality 90%

original
no visual difference
166Kb → 29Kb

Quality 75%

original
not usable
166Kb → 5Kb

Quality 50%

original
not usable
166Kb → 2Kb

My choice here is 90%. 166Kb → 29Kb: 83% leaner!

Avatar

How the algorithm handles faces? Magnificently.

Quality 99%

original
no visual difference
72Kb → 17Kb

Quality 95%

original
no visual difference
72Kb → 13Kb

Quality 90%

original
no visual difference
72Kb → 9Kb

Quality 75%

original
quality drops
72Kb → 4Kb

Quality 50%

original
not usable
72Kb → 3Kb
not usable
72Kb → 3Kb

My choice here is 90% as well. 72Kb → 9Kb. 87% decrease. Holy Moly! By the way, playing with numbers a bit more, I was surprised that I was usually able to see quality drops with textures earlier than with faces.

Tile

One last example. Another texture tile.

Quality 99%

original
no visual difference
36Kb → 9Kb

Quality 95%

original
quality drops
36Kb → 5Kb

Quality 90%

original
not usable
36Kb → 2Kb

Quality 75%

original
not usable
36Kb → 0.32Kb

Quality 50%

original
not usable
36Kb → 0.24Kb

My choice here is 99%. 36Kb → 9Kb. This little texture turned out to be a toughie to compress, with its crisp pixel-wide lines. This time I’ve got only 75% of decrease.

Hats off to the geniuses of computer science who made this possible.


Published: Updated: Author: Ivan Kleshnin