ImageScript - v3.11.0

ImageScript

Discord Server Documentation Github NPM


ImageScript decodes, edits and encodes images in pure TypeScript: no WebAssembly, no native binaries, no dependencies. It runs in Node.js 22.13+, Deno, Bun, browsers and edge runtimes (Cloudflare Workers, Vercel's Edge Runtime, Deno Deploy), works with both import and require(), and ships with type definitions. Large images are encoded and decoded on several threads wherever the runtime supports workers.

npm install imagescript              # Node.js, Bun and bundlers
deno add jsr:@matmen/imagescript # Deno

import { Image } from 'imagescript';
import { readFile, writeFile } from 'node:fs/promises';

const image = await Image.decode(await readFile('input.jpg'));
image.resize(256, Image.RESIZE_AUTO).roundCorners(16);
await writeFile('output.png', await image.encode());

Coordinates start at (0, 0), the top left pixel. For a bigger example, see the script that generates this image:

Example


Format Decode Encode
PNG ✓ ✓
JPEG ✓ ✓
WebP ✓ ✓ (lossless and lossy)
AVIF ✓ ✓ (lossless and lossy)
JPEG XL ✓ ✓ (lossless and lossy)
GIF, APNG (animations) ✓ ✓
BMP, QOI, TGA, Netpbm ✓ ✓
TIFF, ICO/CUR, Radiance HDR ✓

Animations can be decoded from GIF, APNG, WebP and JPEG XL, and encoded as GIF, APNG or WebP, all at once or frame by frame. Embedded color profiles (Display P3, Adobe RGB, ...) are converted to sRGB when decoding, so images look the way browsers show them.

The documentation covers the full API. When upgrading from an older major version, see the changelog. bench/ compares ImageScript's speed and file sizes with Jimp, sharp and other libraries.


ImageScript builds on fflate, libjpeg, pdf.js, font-rs, libwebp, HarfBuzz, dav1d, libavif, libaom, jxl-oxide and libjxl. The TrueType hinting follows FreeType: portions of this software are copyright © 2026 The FreeType Project (www.freetype.org). All rights reserved. See THIRD_PARTY_NOTICES.md for the licenses.


Questions? Join the Discord server.