DEV Community

Андрей Журба
Андрей Журба

Posted on

Your images don't need a server: what I learned building browser-only image tools

Every "free image compressor" website follows the same script: you upload a 12 MB photo to some server, the server compresses it, sends it back, and quietly keeps a copy. I got tired of that pattern and built GetResizer — a suite of image tools (resize, compress-to-exact-size, HEIC/WebP/PDF conversion) that run 100% in the browser. No byte of the user's image ever leaves the machine.

Here's what I learned building it.

1. "Compress to exactly 200 KB" is a binary search problem

Portals (visa forms, government sites, marketplaces) love demanding "photo must be under 200 KB". A quality slider is terrible UX for this. The good approach: binary-search JPEG quality (and downscale if needed) until the output fits the target:

async function compressToTarget(img, targetBytes) {
  let lo = 0.05, hi = 1, best;
  for (let i = 0; i < 8; i++) {
    const q = (lo + hi) / 2;
    const blob = await encode(img, q);
    if (blob.size > targetBytes) hi = q; else { lo = q; best = blob; }
  }
  return best;
}
Enter fullscreen mode Exit fullscreen mode

8 iterations, exact result, zero slider anxiety. This became my most-used feature.

2. HEIC is the real boss fight

iPhone photos are HEIC, and browsers (except Safari) can't decode it. The fix is heic2any — a WASM build of libheif. It works, but:

  • it's ~1.5 MB of WASM, so lazy-load it only when a .heic file is detected;
  • decoding a 12 MP photo on a mid-range phone takes 2-4 seconds — you need progress UI or users think it's broken;
  • EXIF orientation comes through wrong more often than you'd expect. Always respect image-orientation.

3. Canvas has a silent memory ceiling

canvas.toBlob() on a 100 MP image will crash mobile Safari without warning. Cap working resolution and process in tiles for extreme cases. Rule of thumb: keep canvas area under ~268 MP and pixel memory under ~512 MB.

4. Privacy is a feature people actually search for

"image resizer that doesn't upload" is a real query with real volume. For IDs, passports and documents people genuinely don't want server copies. The browser-as-backend pitch is not a gimmick — it's the reason users stay.

5. The boring 80%

  • createImageBitmap decodes 5-10x faster than new Image()
  • OffscreenCanvas + a Web Worker keeps the UI from freezing
  • WebP encoding is universal now; AVIF is still ~10x slower than JPEG to encode client-side
  • for batch jobs (100 files) you need a queue with concurrency limits, or Chrome tabs OOM

Everything is live at getresizer.com — free, no signup, files never leave the device. Happy to answer questions about client-side image processing.

Top comments (0)