RepositoryTypeScriptUSUnited States
a-r-d

a-r-d/PureJsImage

Low-memory, zero-dependency image codecs and processing in pure TypeScript for Node.js, browsers, and serverless runtimes. Bounded decode/resize pipelines plus deep TIFF, scientific raster, GeoTIFF, OME-TIFF, and whole-slide support.

43stars
7forks
1issues
1views
██████╗ ██╗   ██╗██████╗ ███████╗         ██╗███████╗
██╔══██╗██║   ██║██╔══██╗██╔════╝         ██║██╔════╝
██████╔╝██║   ██║██████╔╝█████╗           ██║███████╗
██╔═══╝ ██║   ██║██╔══██╗██╔══╝      ██   ██║╚════██║
██║     ╚██████╔╝██║  ██║███████╗     ╚█████╔╝███████║
╚═╝      ╚═════╝ ╚═╝  ╚═╝╚══════╝      ╚════╝ ╚══════╝
                         I M A G E

First-party image codecs and low-memory raster processing in strict TypeScript

Portable reference engine · optional first-party acceleration · zero runtime dependencies

npm version CI status TypeScript version Node.js version

Zero runtime dependencies MIT license Strict TypeScript reference engine

Documentation · Live browser demo · Whole-slide demo · Install · Quick start · Codecs · Roadmap · Benchmarks

PureJsImage is building a broad suite of first-party image codecs in strict TypeScript. Each codec grows from a checked capability contract and conformance corpus toward broader decode coverage, practical encoding, bounded-memory execution, and optional first-party acceleration.

A shared lazy image and raster pipeline makes those codecs useful across two workload families:

  • Application images: inspect, orient, crop, resize, and transcode common formats.
  • Large and native rasters: TIFF, OME-TIFF, GeoTIFF/COG, whole-slide images, remote regions, and N-channel numeric data.

The same source, codec, and pipeline architecture targets Node.js, modern browsers, serverless, edge, and restricted deployments. It is not a canvas, drawing, or graphics-effects toolkit.

The strict TypeScript reference engine is the permanent portable path. Optional first-party JPEG and PNG WASM accelerators preserve its public behavior and are explicitly registered; they do not replace it. Memory behavior remains codec- and operation-specific: bounded rows or tiles are used where implemented, and full-frame or larger-state fallbacks are documented.

Install

npm install purejsimage

PureJsImage requires Node.js 22 or newer. Browser applications use the purejsimage/browser entry. Installing it adds no runtime dependencies, native addons, or external programs. Optional first-party JPEG and PNG WASM accelerators use separate explicit entries.

Pre-1.0: Codec behavior is heavily tested, but public APIs may receive breaking refinements before 1.0.

Read the installation and browser guide →

Quick start

Common image pipeline

Register only the codecs the application needs, then build a processing pipeline:

import { createImageLibrary } from 'purejsimage'
import { jpegCodec } from 'purejsimage/codecs/jpeg'
import { pngCodec } from 'purejsimage/codecs/png'

// Optional first-party WASM accelerators:
import { wasmJpegAccelerator } from 'purejsimage/accelerators/wasm/jpeg'
import { wasmPngAccelerator } from 'purejsimage/accelerators/wasm/png'

const images = createImageLibrary({
  codecs: [jpegCodec, pngCodec],
  accelerators: [wasmJpegAccelerator, wasmPngAccelerator], // Optional
})
const image = await images.open('input.jpg')

await image
  .autoOrient()
  .resize({ width: 1200, withoutEnlargement: true })
  .jpeg({ quality: 80, background: '#ffffff' })
  .toFile('output.jpg')

In a browser, import from purejsimage/browser and use toBlob() or toUint8Array() for output. Tools that need every default codec can register allCodecs from purejsimage/codecs/all.

TIFF with a scientific profile

Register the TIFF codec alone, then opt into the OME-TIFF profile:

import { createImageLibrary, FileSource } from 'purejsimage'
import { tiffCodec } from 'purejsimage/codecs/tiff'
import { omeTiffProfile } from 'purejsimage/scientific'
import { createTiffProfileRegistry, openTiffDocument } from 'purejsimage/tiff'

const images = createImageLibrary([tiffCodec])

const source = await FileSource.open('input.ome.tif')
const document = await openTiffDocument(source)
const profiles = createTiffProfileRegistry([omeTiffProfile])
const dataset = await profiles.openWith(document, omeTiffProfile)

Live browser demo

Open the client-side image converter →

Upload an image, let PureJsImage detect its actual format, apply optional orientation, resize, rotation, and flip transforms, then download JPEG, PNG, WebP, BMP, or TIFF output. The demo runs entirely in the browser, makes no image-upload request, and reports conversion time plus the browser memory measurements it can honestly observe.

Browse a 2.12 GB pathology slide after fetching a fraction of a percent →

The zero-dependency whole-slide demo reads native Aperio SVS pyramid tiles directly from static object storage with HTTP Range. It measures real requests and transferred bytes, cancels offscreen tile work in a Web Worker, and requires no conversion, tile server, or sidecar index.

Optional WASM acceleration

JPEG and PNG have optional first-party WebAssembly accelerators. They are never loaded unless you explicitly register them, and unsupported work continues to use the default TypeScript codecs.

See WASM setup, options, and supported workflows →

Supported codecs

FormatReadWrite
JPEGYesYes
PNGYesYes
WebPYesYes
BMPYesYes
TIFFYesYes
GIFStatic / explicit frame 0No
ICOYesNo
JPEG 2000 / JP2LimitedNo
AVIFLimitedNo
HEIF / HEIC (experimental)ExperimentalNo

“Limited” means PureJsImage supports a useful subset and clearly rejects files outside it. “Experimental” means the codec is excluded from allCodecs and requires an explicit direct import and registration.

See the exact codec support matrix →

Detailed codec compatibility roadmaps: JPEG, PNG, WebP, BMP, TIFF, GIF, ICO, JPEG 2000 / JP2, AVIF, and HEIF / HEIC (experimental).

HEIF/HEIC is experimental, excluded from allCodecs, and available only through purejsimage/codecs/experimental/heic. Its support contract includes the HEVC patent notice for users and distributors.

AVIF is an active first-party codec project, not a wrapper around libavif or a third-party runtime. The checked capability contract defines the currently validated still-image decode subset; broader decode coverage is expanding, and a constrained encoder is planned after the decoder reaches its intended maturity.

Beyond ordinary image conversion

The raster APIs preserve native numeric data instead of forcing every source through RGB:

  • Scientific: N-channel rasters and OME-TIFF.
  • Geospatial: GeoTIFF and remote COG region reads.
  • Pathology: whole-slide pyramids, Aperio SVS, and vendor profiles.

The Image pipeline uses display-ready PixelBlocks for ordinary transformations and encoding. Scientific TIFF workflows expose native numeric, N-channel RasterBlocks and map them to an Image only when requested.

TIFF

TIFF support spans display images, native scientific rasters, OME-TIFF, whole-slide pyramids, extensible vendor profiles, and canonical RGB/RGBA output. The complete support list, memory model, examples, and remaining boundaries live on the dedicated TIFF page:

TIFF library comparison

A capability is Yes only when upstream documentation or source supports it; measured decode coverage is reported separately against independent RGBA output. “Not verified” is not treated as unsupported.

LibraryRuntime modelBrowserBigTIFFTilesRegion decodeNative scientific rasterOME / whole-slide semanticsDecode coverage
PureJsImage benchmark snapshot · a1f20daStrict TypeScriptYesYesYesYesYesYes104/106 decoded
57 exact
2 oracle failures
GeoTIFF.js 3.0.5Pure JavaScriptYesPartialYesYesYesNo84/106 decoded
32 exact
11 unsupported · 7 errors · 2 oracle failures · 2 crashes
UTIF.js (utif2) 4.1.0Pure JavaScriptYesNoYesNoPartialNo74/106 decoded
49 exact
28 errors · 2 oracle failures · 2 timeouts · 3 crashes
image-js/tiff 7.1.3Pure JavaScriptYesNoYesNoYesNo41/106 decoded
27 exact
51 unsupported · 12 errors · 2 oracle failures
image-js 1.7.0Pure JavaScriptYesNoYesNoPartialNo39/106 decoded
33 exact
51 unsupported · 14 errors · 2 oracle failures
Jimp 1.6.0Pure JavaScriptYesNoYesNoNoNo74/106 decoded
49 exact
28 errors · 2 oracle failures · 2 timeouts · 3 crashes
Sharp / libvips 0.35.3Native wrapperNoPartialYesPartialPartialNoNot run

Full grouped capability matrix, methods, sources, and per-library results

Benchmarks

The seven-engine competitor profile measures the default PureJsImage TypeScript codecs and the explicitly registered PureJsImage JPEG/PNG WASM accelerators as separate variants alongside Jimp, Sharp, Sharp configured for one processing thread, image-js, and jSquash. Sharp uses native libvips; PureJsImage WASM and jSquash use WebAssembly; default PureJsImage, Jimp, and image-js are pure JavaScript. Each engine received the same files, used its public default resize kernel, and ran in a separate process. A result appears only when its output passed validation.

Image workflow speed comparison across seven isolated engines, including default and WASM PureJsImage variants.

Image workflow output quality comparison across seven engines measured as premultiplied-RGBA PSNR against an exact-area reference.

Image workflow absolute peak memory comparison across seven isolated engines.

Resize workflows use engine defaults: PureJsImage and Sharp use Lanczos 3 while Jimp uses bilinear. The quality chart reports premultiplied-RGBA PSNR against an independently decoded exact-area reference; exact means every visible color and alpha channel matched. This exposes quality differences, but cross-kernel timings remain default-experience measurements rather than matched-quality comparisons.

Benchmark snapshot: PureJsImage 0.8.0, August 10, 2026, Node.js 24.16.0. Against the default TypeScript path, the opt-in WASM variant reduced median wall time by 53.0% for JPEG-to-PNG, 38.9% for the 100-megapixel PNG downscale, and 11.6% for the large PNG resize while returning the same measured output quality. On the 24-megapixel photo workflow, default PureJsImage used 86.7% less peak memory than Jimp and 87.6% less than image-js. Timing, memory, and quality vary by image, operation, machine, and library version.

The focused nine-run TIFF profile recorded:

WorkflowPureJsImage wallPureJsImage RSSJimp wallJimp RSS
4000×3000 TIFF metadata0.4 ms134.4 MiB150.4 ms289.8 MiB
4000×3000 TIFF → 1000px JPEG144.4 ms214.9 MiB663.0 ms372.1 MiB
7795×3122 LZW TIFF → 1000px PNG1,026.2 ms133.0 MiB753.2 ms284.8 MiB
PNG → Deflate TIFF24.5 ms111.4 MiB97.3 ms152.8 MiB

PureJsImage passed all 18 TIFF workflows. Jimp passed seven, lacked the eight bounded raw/region workflows, and produced invalid pixels in three decode-to-PNG cases. The LZW row is the measured exception to the speed advantage: PureJsImage was slower there but used 53.3% less peak RSS.

Raw competitor report · PureJsImage TIFF report · Jimp TIFF report

See the complete benchmark report and methodology →

Lambda memory sizing

A 256 MiB Lambda completed every measured 12-megapixel resize/conversion workflow and used 121–156 MiB at peak. That does not make 256 MiB the fastest setting: Lambda also allocates CPU with memory. For JPEG → WebP, warm operation time fell from 10,601 ms at 256 MiB to 5,261 ms at 512 MiB and 2,533 ms at 1024 MiB, while peak use stayed at 120–122 MiB. For latency-sensitive endpoints, start at 1024 MiB even when the process only consumes about 150 MiB; use 256 MiB when its lower CPU allocation and roughly 10-second latency are acceptable. Re-measure with your own images and concurrency.

Bundle size

JPEG and PNG form the matched set because all five libraries support them. PureJsImage and jSquash can assemble only that set; the normal Jimp, image-js, and Sharp imports include the additional codecs shown.

Measured on Linux x64 with Node.js 24.16.0 using the repository's reproducible esbuild, gzip, and Brotli settings:

ImportVersionCodecs includedMinified JSgzipBrotli
PureJsImage matched0.9.0JPEG, PNG145.4 KiB47.2 KiB39.6 KiB
PureJsImage all codecs0.9.09 codecs668.9 KiB240.7 KiB201.6 KiB
Jimp1.6.0JPEG, PNG, TIFF, BMP, GIF577.4 KiB174.6 KiB139.5 KiB
image-js1.7.0JPEG, PNG, TIFF, BMP361.5 KiB111.2 KiB94.3 KiB
jSquashJPEG 1.6.0; PNG 3.1.1; resize 2.1.1JPEG, PNG52.4 KiB16.0 KiB13.2 KiB
Sharp JS wrapper0.35.3JPEG, PNG, TIFF, WebP, GIF, AVIF128.4 KiB38.3 KiB33.5 KiB

Sharp's JavaScript bundle is only a wrapper around native code, while jSquash's JavaScript bundle is glue around its WebAssembly codecs and resizer. The complete installed deployment tells the other half of the story:

PackageVersionInstalled footprintProduction packages
PureJsImage0.9.02.3 MiB1
Jimp1.6.029.3 MiB70
image-js1.7.017.0 MiB46
jSquash JPEG + PNG + resizeJPEG 1.6.0; PNG 3.1.1; resize 2.1.11.0 MiB3
Sharp, including native libvips0.35.318.9 MiB6

See bundle details and reproduction commands →

Why PureJsImage?

  • First-party codecs implemented in this repository, with strict TypeScript as the permanent portable reference engine.
  • Zero runtime dependencies and no required native image stack, WebAssembly, or external binaries.
  • Codec-native bounded execution where the format permits it, with explicit memory classes and documented full-frame fallbacks.
  • The same reference behavior across Node.js and modern browsers.
  • Explicit unsupported boundaries instead of plausible corruption.
  • Permanent conformance corpora, hostile-input tests, and reproducible performance and memory measurements.
  • Optional first-party acceleration that preserves the reference contract rather than replacing it.

When to use Sharp instead

If you can deploy native libvips and throughput or latency is the main constraint, use Sharp. It was 1.9×–12.2× faster than the default TypeScript path across the five commonly supported benchmark workflows. PureJsImage is the better fit when the same code must run in Node.js and browsers or edge workers, native addons or WASM are prohibited, or a zero-dependency deployment materially simplifies an air-gapped or supply-chain-restricted build. The measured installed footprint was 2.3 MiB and one package for PureJsImage versus 18.9 MiB and six production packages for Sharp.

Read the practical guides →

Development

The repository uses TypeScript strict mode, Biome, and Vitest.

npm install
npm run check

Read the contributor guide →

See CONTRIBUTING.md for the repository checklist and the project specification for the architecture and implementation principles.

The detailed implementation and acceleration plans remain in the project roadmap.

Similar Projects

Discover other similar projects and AI models.

RepositoryTypeScript
jimp-dev/jimp

Image processing in pure JavaScript for Node.js and the browser, with zero native dependencies.

14.7k
Nov 30, 2026
RepositoryGo
imgproxy/imgproxy

Fast and secure standalone server for resizing, processing, and converting images on the fly

11.2k
Nov 30, 2026
RepositoryGo
h2non/imaginary

Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing

6.1k
Nov 8, 2025
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryTypeScript
freeCodeCamp/freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.

459.9k
Dec 2, 2026
RepositoryTypeScript
vuejs/vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

212.6k
Oct 10, 2024
RepositoryPython
practical-tutorials/project-based-learning

Curated list of project-based tutorials

290.9k
Nov 30, 2026
RepositoryJavaScript
react/react

The library for web and native user interfaces.

253.0k
Nov 30, 2026
RepositoryJavaScript
trekhleb/javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

196.8k
Jul 26, 2026