GitHunt
SI

NPM package to manipulate images

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.x browser 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 as brightnessImageData, contrastImageData, and sepiaImageData
  • catalog introspection through getTransformCatalog()
  • canvas helpers readImageDataFromCanvas and writeImageDataToCanvas

Backward-compatible aliases are kept for older helper names such as readCanvasImageData, writeCanvasImageData, and applyTransformToCanvas.

Current transforms

  • grayscaleImageData
  • invertImageData
  • blurImageData
  • brightnessImageData
  • contrastImageData
  • thresholdImageData
  • sharpenImageData
  • saturationImageData
  • sepiaImageData
  • opacityImageData
  • gammaImageData
  • resizeImageData
  • composeImageDataTransforms

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 .wasm asset emitted by wasm-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 bindings
  • react/ contains the showcase app
  • examples/ contains minimal consumption examples
  • docs/ contains architecture and troubleshooting notes
  • CONTRIBUTING.md covers local setup and release expectations
  • CHANGELOG.md tracks shipped changes

Local development

Prerequisites:

  • Rust stable with cargo
  • wasm-pack
  • Node.js with npm

Common commands:

make install
make test
make build
make smoke

For browser wasm integration tests and publish-artifact verification:

make wasm-test
make release-check

Additional docs

Languages

JavaScript40.7%Rust39.6%CSS17.7%Makefile1.7%HTML0.3%

Contributors

Other
Created October 25, 2023
Updated March 11, 2026
sinansonmez/resim | GitHunt