Small confession: this site was shipping about 5 MB of avatars and event photos, mostly full-size JPEGs shown at thumbnail size. Now every image is a right-sized WebP, generated at build time by Image, the libvips-backed library from Kip Cole.
There's a nice symmetry to it: Kip gave a talk at Elixir Sydney in May 2024, Fast and efficient image processing in Elixir, on exactly this topic, using libvips, Vix and Image to scale, transform and compose images fast. We're now running his library to build the very page you're reading.
What it does for us
- A
mix imagesbuild step walks the image folder and writes a right-sized.webpnext to each source (avatars capped at 160px, event photos at 800px). On-page images dropped from roughly 5 MB to about 900 KB. - The OpenGraph share cards are re-encoded to lossless WebP through the same
library (libvips'
webpsave), taking the card set from around 26 MB to 9 MB with no loss of crispness on the text. - It's self-contained: Vix ships a precompiled libvips, so there's nothing to install in CI.
Image is a lovely piece of the ecosystem: a clean Elixir API over a very fast C library, precompiled so it just works. If you push images around in an Elixir app, watch Kip's talk and reach for Image.