NATIVE NODE ADDON · POWERED BY RUST

Fast image processing
in Rust.

Encode, compress, resize and convert images — JPEG, PNG, WebP, AVIF and more — with a native Node addon that beats sharp.

$vp add @napi-rs/image
transform.ts
import { Transformer, ChromaSubsampling } from '@napi-rs/image'

const webp = await new Transformer(input)
  .rotate()
  .resize(225)
  .webp(75)

const avif = await new Transformer(input)
  .rotate()
  .resize(225)
  .avif({
    quality: 70,
    chromaSubsampling: ChromaSubsampling.Yuv420,
  })
1.8×
faster WebP encode vs sharp
14
image formats
−51%
smaller, lossless
01 — BENCHMARK

Faster than sharp

Apple M1 Max · macOS 12.3.1 · node bench/bench.mjs. Pipeline: rotate → resize(225) → encode.

peak speedup

1.8×

faster WebP encode with UV_THREADPOOL_SIZE=10. AVIF lands at near-parity — WebP is where the gap opens up.

defaultbaseline
WebP1.20× sharp
napi
202 ops/s
sharp
169 ops/s
AVIF1.08× sharp
napi
26 ops/s
sharp
24 ops/s
UV_THREADPOOL_SIZE=10fastest
WebP1.81× sharp
napi
431 ops/s
sharp
238 ops/s
AVIF1.13× sharp
napi
36 ops/s
sharp
32 ops/s

Apple M1 Max · macOS 12.3.1 · node bench/bench.mjs. Pipeline: rotate → resize(225) → encode.

02 — COMPRESSION

See the bytes disappear

Drag to compare original and optimized — same image, a fraction of the size.

new Transformer(PNG).webp(75)original
new Transformer(PNG).webp(75)Lossy
1192 KB83 KB−93%
new Transformer(PNG).avif({ quality: 75 })original
new Transformer(PNG).avif({ quality: 75 })Lossy
1192 KB108 KB91%
pngQuantize({ maxQuality: 75 })original
pngQuantize({ maxQuality: 75 })Lossy
1192 KB217 KB82%
new Transformer(PNG).avif({ quality: 100 })original
new Transformer(PNG).avif({ quality: 100 })Lossless
1192 KB581 KB51%
new Transformer(PNG).webpLossless()original
new Transformer(PNG).webpLossless()Lossless
1192 KB673 KB44%
losslessCompressPng()original
losslessCompressPng()Lossless
1192 KB873 KB27%
compressJpeg(JPEG, { quality: 75 })original
compressJpeg(JPEG, { quality: 75 })Lossy
192 KB100 KB48%
compressJpeg()original
compressJpeg()Lossless
192 KB182 KB5%
03 — FORMATS

Every format you need

WebP and AVIF are fully bidirectional — decode and encode. HDR and DDS are decode-only.

FormatDecodeEncodeNotes
JPEGrw
PNGrw
WebPrw
AVIFrw
TIFFrw
BMPrw
ICOrw
TGArw
PNMrw
farbfeldrw
RawPixels (RGBA8)rw
SVGinput only
DDS (DXT1/3/5)decode only
HDR (Radiance)decode only

14 formats total · 11 bidirectional · 3 decode-only

04 — FILTERS

Built-in filters

grayscale, blur, hue-rotate, contrast and more — applied natively in Rust.

grayscale
grayscale
invert
invert
blur
blur
huerotate
huerotate
contrast
contrast
brighten
brighten
crop
crop
05 — PIPELINE

One pipeline

From raw bytes to every format — a few lines, all native.

optimize.ts
import { readFileSync, writeFileSync } from 'node:fs'
import { Transformer, losslessCompressPng, ResizeFilterType, ChromaSubsampling } from '@napi-rs/image'

const PNG = readFileSync('./input.png')

writeFileSync('out.png', await losslessCompressPng(PNG))
writeFileSync('out.webp', await new Transformer(PNG).resize(800, null, ResizeFilterType.Lanczos3).webp(75))
writeFileSync('out.avif', await new Transformer(PNG).resize(800, null, ResizeFilterType.Lanczos3)
  .avif({ quality: 75, chromaSubsampling: ChromaSubsampling.Yuv420 }))

PLAYGROUND

Try it in your browser

The WASM build runs entirely client-side — no install, no upload.