HPR4732: Webp

Di Klaatu22/09/2026 às 00:0039 visualizzazioni
Foto: CC BY-SA / Hacker Public Radio
🎙 Klaatu · Hacker Public Radio

This show has been flagged as Clean by the host.

Webp is meant to replace GIF, JPEG, and PNG.

Its features include:

  • Lossy compression

  • Lossless compression

  • Metadata, including Exchangeable Image File Format (EXIF) and Extensible Metadata Platform (XMP)

  • Transparency (an "alpha channel")

  • Embedded ICC (International Color Consortium) profile

  • Multiple frames (animation)

The typical expectation is to achieve equal or better visual quality as a JPEG or PNG or GIF, but with a savings of 25% to 35% on file size.

This is famously difficult to measure, because if you concede to an equal file size, then the quality ought to be better, but there is a "ceiling" to quality that can be detected by the majority of human eyes.

So the metric is the unmeasurable: How good does it look to you?

If it looks as good or better, and the file size is smaller, then it can be said that the format is superiour.

The best and most common test is to look at an image compressed with JPEG or PNG compression, and then look at the same image compressed by WEBP.

If you can't tell the difference, and the file size of WEBP is smaller, then it's an improvement for disk space and bandwidth.

WEBP is an 8-bit format (based on the VP8 video codec) and lacks support for 10-bit, 12-bit, or 16-bit colour.

Specifically, WEBP is YUV420, where Y is Luma (brightness and darkness), and U and V are Chroma (colour).

Each 8-bit pixel in the UV (Chroma) corresponds to a 2-by-2 block of 8-bit Luma pixels, or in other words, Chroma gets half the resolution of Luma.

This is not uncommon, because how sharp an image appears to the human eye is mostly (not entirely, to be fair) influenced by Luma.

Our eyes differentiate bright from dark better than our eyes perceive subtle shifts in hue.

The ICCP chunk starts with a 4-byte declaration (the ASCII string "ICCP"), then a 32-bit integer representing the length of the payload, then the payload (the ICC profile specification according to the International Color Consortium), and then optionally a byte to pad the header.

The embedded ICC profile can define any old colour space you want.

If none is defined, sRGB is assumed.

The libwebp library only parses the ICC profile, it doesn't actually handle conversion.

That's left to the client application, which is why you might get a notice sometimes in GIMP or a similar application about a colour space mismatch.

(It's generally safe to convert to your current colour space, and if it's not then you'd know it because you're working in a multimedia production house where colour spaces and colour profiles are significant.)

Converting to WEBP is available in most applications, at this point, including Image Magick and the cwebp command.

Image Magick:


$ convert foo.tiff foo.webp

Or using cwebp with -q for a quality 0 (low) to 100 (high), and -o for output:


$ cwebp foo.tiff -q 60 -o foo.webp

Test images are available from a Mozilla test suite.

Or you can test on a Hacker Public Radio image, such as the screenshot of the upload form on the episode_show_notes page:


$ wget https://hackerpublicradio.org/images/upload_form.png

$ cwebp upload_form.png -q 50 -o upload_form.webp

$ ls -gl

-rw-r--r-- 1 users 308K Sep 16 13:56 upload_form.png

-rw-r--r-- 1 users 79K Sep 16 13:57 upload_form.webp

References

Provide feedback on this episode.

Fonte
Hacker Public Radio
Apri l'originale ↗
Questa notizia è stata utile?

Dibattiti 0

Sii il primo a contribuire al dibattito.

Condividi le tue informazioni e promuovi il tuo argomento

Non esitare a pubblicare informazioni o dati che possano essere utili.

Per partecipare al dibattito, accedi o crea un account gratuito.