Skip to content

@dusrel/imageClient-side image processing, done properly

Compress, crop, resize, rotate and convert images entirely in the browser. No backend, no uploads, no server cost — with WASM codecs and maximum developer control.

Dusrel logo

In one line ​

ts
import { processImage } from '@dusrel/image';

const { blob, report } = await processImage(file, {
  format: 'image/webp',
  maxSizeBytes: 200_000, // byte budget — the engine searches quality for you
});
24packages, one lockstep version
10WASM codecs, lazily loaded
3browser engines proven on CI
0servers, uploads or tracking

Why client-side? ​

Private by architecture

There is no upload endpoint, so there is nothing to leak, breach or subpoena. Your users' photos never leave their device — compliance reviews get very short.

Zero running cost

The visitor's CPU does the work. No image servers to host, scale, patch or pay for — a static site and this library are the whole infrastructure.

Embeds anywhere

Single-threaded WASM by default: no SharedArrayBuffer, no COOP/COEP headers, no cross-origin isolation. Drop it into any page, widget or webview.

Three ways to use it ​

ts
import { processImage } from '@dusrel/image';

const { blob, report } = await processImage(file, {
  format: 'image/webp',
  quality: 0.8,
  resize: { width: 1600 },
  crop: { x: 80, y: 60, width: 640, height: 480 },
});

console.log(report.stepsApplied, report.savingsRatio);
ts
import { pipeline, codecPlugin, imageDataPlugin } from '@dusrel/image';
import { encode } from '@dusrel/image-avif';
import { adjust } from '@dusrel/image-adjust';

const { blob } = await pipeline(file)
  .resize({ width: 1200 })
  .use(imageDataPlugin({ name: 'adjust', transform: (d) => adjust(d, { saturation: 0.1 }) }))
  .use(codecPlugin({ mimeType: 'image/avif', encode: (d) => encode(d, { quality: 55 }) }))
  .run();
tsx
import { useProcessImage } from '@dusrel/image-react';

function Compressor() {
  const { process, processing, progress, result } = useProcessImage();
  return (
    <>
      <input type="file" accept="image/*" onChange={(e) => {
        const f = e.target.files?.[0];
        if (f) void process(f, { format: 'image/webp', quality: 0.8 });
      }} />
      {processing && <progress value={progress} max={1} />}
      {result && <img src={URL.createObjectURL(result.blob)} alt="" />}
    </>
  );
}

The family at a glance ​

GroupPackagesWhat's inside
Core2@dusrel/image (flagship) + the zero-dependency canvas engine
Codecs10MozJPEG, libwebp, libavif, Rust PNG/QOI, OxiPNG, quantize, resize, libjxl, libheif (HEIC decode)
Features9Crop component, transform, adjust, metadata, watermark, batch, GIF, SVG, placeholders
Frameworks3React, Vue and Svelte bindings with typed crop components

See all 24 packages → · Cookbook: tasks mapped to packages →

Browser support ​

Every package's browser spec runs on CI in Chromium, Firefox and WebKit (Playwright) — the 1.0.x releases are green on all three.

Chrome / EdgeFirefoxSafari
Core + canvas formats (16.4+ for the worker path)
WASM codecs
HEIC decode WASM fallback WASM fallback Native (17+), WASM elsewhere

Full support matrix and known quirks →

FAQ ​

Is it really free? What does it cost to run?

Yes — MIT licensed (the HEIC decoder's engine is LGPL-3.0, fenced inside its own package; see ADR-0008). Running cost is zero: all processing happens on your visitors' devices.

Which formats can it produce?

Built in: JPEG, PNG, WebP. Register a codec package to add AVIF, JPEG XL, QOI and GIF — plus MozJPEG/libwebp/Rust-PNG encoders that outperform the canvas ones. HEIC is decode-only (there is no permissively licensed HEVC encoder).

My Vite dev server serves HTML instead of the WASM file. Why?

Vite's dev pre-bundling relocates the codec code and breaks its relative asset URLs. Exclude the codec packages from optimizeDeps, or pass explicit URLs with setCodecAssets — both fixes are written up in Bundlers & codec assets.

Do I need COOP/COEP headers or a special server?

No. The default builds are single-threaded and need no SharedArrayBuffer. Just serve .wasm as application/wasm, which every static host does by extension.

Can it hit an exact file-size target?

Give maxSizeBytes and the engine searches quality for you. result.targetSizeMet reports honestly whether the budget was met — the smallest best-effort result is returned either way.

Try every codec in your browser

The playground runs the whole family live — no install, no uploads.