WebP conversion
I just spent about an hour learning about converting images to WebP. For my linkblog; I want my link previews to be small files. Target display is 320x180ish images.
Here’s where I landed to resize everything to 640 pixels wide with a fairly high quality:
cwebp -quiet
-af -q 90
-resize 640 0
-metadata all
These are guesses but seem to work about right.
-af -q 90 are the quality settings. 90 is fairly high, the default is 75. af means “spend more time making it look good”, it seems to take about 2x as long. I also experimented with the -m setting to trade off time vs compression quality but the default -m 4 seems fine to me.
The resize forces all images to a width of 640 and whatever height is natural. Twice the target display resolution for retina display.
The one surprise is some of the images (but only some) seem to get a little brighter after conversion. I thought that was a symptom of ICC color profiles not being applied right, which is why I added the -metadata all flag. But it’s still happening. I don’t care enough to figure it out; it could just be the difference in the browser resize algorithm vs cwebp.
Starting with a bunch of 1280x720 screenshot PNGs the webp versions are about 10% the size. If I leave out the image resizing it’s about 25%. That’s mostly thanks to the lossy compression which is fine for my purposes given I’m resizing too.
Overall this got my full page down from 24MB to 2MB. Worth the time!