Blog / Website speed

I built an image optimiser that never uploads your photos

ImageShip shrinks photos to WebP and AVIF in your browser, with no upload and no server.

ImageShip is a free tool I built that takes your photos and gives back small, sharp WebP and AVIF files, plus the code to paste into your page. It also makes a full favicon set from one logo. There’s no server, so your photos never leave your computer: it all happens in the browser tab.

ImageShip with three 4000px photos added, the WebP and AVIF formats ticked, widths and quality settings on the right, and the note that images are never uploaded

Photos straight off a phone are several megabytes each, and on a web page every visitor downloads all of that. A typical result from the tool is a 4000px photo going from 2.5 MB to 255 KB at the default settings. It’s the same picture, about 90% smaller.

ImageShip’s results for three photos: 5.9 MB of originals down 95%, with one hero image going from 2.1 MB to 136 KB and the picture element code ready to copy

Why I built my own

I don’t always get to use Astro. It’s great because it resizes and converts your images for you at build time, but plenty of the sites I work on are WordPress, Umbraco or some other CMS, where nothing does that for you. Even on static sites, I sometimes want more control than a build step gives me.

I’d also run into images being compressed more than I wanted. I wanted to pick the quality and the widths myself, do a whole folder in one go, and see exactly what had happened to each image before it went anywhere near the site, so ImageShip shows every image’s original size next to its new size, and the weight of each width.

Having no server gave me two more things I wanted. Your files can’t leak because they never go anywhere, and there’s nothing for anyone to run up a bill on, because the app is only static files with no code of mine running on a server.

That was a choice I made on purpose, and it caused some interesting problems. Here are the ones I enjoyed.

Using your browser where it can

To turn a photo into WebP, the app first checks whether your browser can do it natively. Chrome and Edge can, and it’s quick, while other browsers get a WebAssembly encoder instead. AVIF always uses WebAssembly, and it’s only downloaded if you tick AVIF, so people who only want WebP never pay for it. AVIF also needs a lower quality number to look the same as WebP, so the app multiplies yours by 0.75 before encoding.

Not crashing your tab

If someone drops in a huge photo, decoding it at full size could use more memory than a browser tab is allowed, so the app shrinks it while it decodes and never holds the full-size version in memory. The cap is 50 megapixels, or 16 on an iPhone or iPad, which have far less room, and anything over 100 megapixels is refused. Files are checked by their first few bytes, not their name, so a PDF renamed to holiday.jpg is turned away.

The encoding runs in a small pool of background workers so the page stays responsive. When you hit cancel I terminate them outright instead of asking nicely, so a runaway batch can always be stopped, and if one crashes, usually from running out of memory, only that one image fails and a fresh worker takes its place. WebP is made for every image first and AVIF after, so you’ve got usable results while the slow ones are still cooking.

The headers that forced it onto its own Worker

This is my favourite bit. AVIF is faster when it can use several CPU threads, and browsers only allow that on a page that’s “cross-origin isolated”. That takes two headers, Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy, and they affect everything on the page: what it can embed, and which outside scripts it can load.

I didn’t want those rules applied to the rest of my site, so ImageShip lives in its own project, with its own Cloudflare Worker on the route /imageship/app/*. The more specific route wins, so the app gets its headers and the rest of the domain is untouched. Even my analytics script had to be loaded in a particular way to get past them. Without those headers, AVIF still works, just slower.

Try it

ImageShip is free, needs no account, and runs in any current browser. If you’ve got a folder of photos on your phone, it’s a decent way to see how much of your website is just oversized pictures.

How's your site doing?

Send me your website and I'll check it for free, tell you its score, and give you the three things I'd fix first.

Get a free website checkStart my website