Resim
Resim is a browser image toolkit built with Rust and WebAssembly.
The repository contains a validated Rust core for RGBA pixel transforms, wasm bindings for browser consumers, and a React demo that exercises the public browser API.
Positioning
Resim is currently positioned as:
- a browser-first image toolkit with a small, explicit public API
- a reference demo for consuming the generated wasm package
- a semver-managed toolkit with a stable
1.xbrowser API baseline
Crop and rotate remain intentionally out of scope for the current line, but nearest-neighbor resize is included.
Stable API surface
The stable browser-facing surface for the 1.x line is:
- wasm initialization through the default export
ImageData-first transforms such asbrightnessImageData,contrastImageData, andsepiaImageData- catalog introspection through
getTransformCatalog() - canvas helpers
readImageDataFromCanvasandwriteImageDataToCanvas
Backward-compatible aliases are kept for older helper names such as readCanvasImageData, writeCanvasImageData, and applyTransformToCanvas.
Current transforms
grayscaleImageDatainvertImageDatablurImageDatabrightnessImageDatacontrastImageDatathresholdImageDatasharpenImageDatasaturationImageDatasepiaImageDataopacityImageDatagammaImageDataresizeImageDatacomposeImageDataTransforms
The Rust core also exposes apply_transform_sequence for validated multi-step transform composition.
Supported environments
Officially supported today:
- modern evergreen browsers with WebAssembly and
ImageData - bundlers that can consume ESM wasm output generated by
wasm-pack --target web - local development with Rust stable,
wasm-pack, Node.js, and npm
Expected bundler behavior:
- the app or package consumer must await the wasm default initializer before calling exports
- the bundler must support loading the generated
.wasmasset emitted bywasm-pack - the current demo is verified with webpack 5
Browser API examples
Parameterized transform:
import {
default as init,
brightnessImageData,
readImageDataFromCanvas,
writeImageDataToCanvas,
} from "resim";
await init();
const imageData = readImageDataFromCanvas(canvas, ctx);
const transformed = brightnessImageData(imageData, 30);
writeImageDataToCanvas(ctx, transformed);Chained workflow:
import {
default as init,
contrastImageData,
sepiaImageData,
} from "resim";
await init();
const boosted = contrastImageData(imageData, 25);
const vintage = sepiaImageData(boosted);Canvas convenience helper:
import { default as init, applyCanvasTransform, TransformKind } from "resim";
await init();
applyCanvasTransform(canvas, ctx, TransformKind.Blur);The canvas helper remains a convenience API. The primary long-term surface is still ImageData-first.
Demo capabilities
The React demo currently supports:
- preset-driven look selection with one-click apply
- fine-tune inspector controls powered by the wasm-exported transform catalog
- local image upload and sample-image restore
- side-by-side original vs processed comparison
- undo and reset flows
- processed PNG export
- responsive action controls with a custom CSS layout
Versioning and deprecation
Current versioning rules:
- crate and demo versions move together inside this repository
- breaking browser API changes require a major version bump
- minor versions add backward-compatible capabilities within the active major line
- new APIs should be added before old aliases are removed
- renamed browser exports should ship with at least one documented release of overlap
Repo layout
rust/contains the Rust core and wasm bindingsreact/contains the showcase appexamples/contains minimal consumption examplesdocs/contains architecture and troubleshooting notesCONTRIBUTING.mdcovers local setup and release expectationsCHANGELOG.mdtracks shipped changes
Local development
Prerequisites:
- Rust stable with
cargo wasm-pack- Node.js with npm
Common commands:
make install
make test
make build
make smokeFor browser wasm integration tests and publish-artifact verification:
make wasm-test
make release-check