Post

My thoughts on WebP

I really don’t understand the hate for WebP. It was sort of sabotaged by Adobe (they didn’t support it for 13 years!) but I don’t think that stops it from being a great format. Pretty much every image on this site is WebP which helps a lot for load times on image-heavy pages like the album one, but no one even notices it because it functions fine until you try to import it into your shitty pirated paint app from 2009. There’s really no difference in quality, even with a png 10x it’s size.

WebP also works on every modern browser past 2014 and it completely replaces gif, jpg and png with it’s lossless/lossy compression, animation and transparency. I wish it came earlier, but I find that everything I use supports WebP by now.

Here’s the bash function I use to convert images to WebP. Just add it to your .bashrc and runoptimize filenameand it’ll replace your old images with WebP. You can also specify quality with the -q flag.

optimize() {
    local quality=80
    while [ "$#" -gt 0 ]; do
        case "$1" in
            -q)
                quality="$2"
                shift 2
                ;;
            *)
                break
                ;;
        esac
    done
    echo "Quality: $quality"
    for file in "$@"; do
        if [[ $file != *.webp ]]; then
            basename=${file%.*}
            cwebp -m 6 -q $quality "$file" -o "$basename.webp"
            rm "$file"
        else
            mv "$file" "$file.old"
            cwebp -m 6 -q $quality "$file.old" -o "$file"
            rm "$file.old"
        fi
    done
}

For a comparison, here’s an image I was using on the albums page. WebP gets it 8x smaller with no noticeable difference.

The Miseducation of Lauryn Hill album cover, repeated twice
JPG, 3.8M

WebP, 448K


Really, I would prefer to use JPEG XL but I suppose it takes a while for better formats to catch on. Maybe after safari implements it.