Getting Started
zenpix exposes a native C image-processing engine through a TypeScript API and CLI. It decodes JPEG / PNG / WebP / AVIF / GIF / HEIC and encodes WebP / AVIF / PNG after Lanczos-3 resizing on Node.js, Bun, and Deno.
The browser package zenpix-wasm only encodes raw RGB / RGBA pixels to AVIF. It does not include native zenpix decoding, resizing, or the CLI.
- npm (server): https://www.npmjs.com/package/zenpix
- npm (browser/WASM): https://www.npmjs.com/package/zenpix-wasm
- GitHub: https://github.com/tsukasa-art/zenpix
Install
Section titled “Install”Node.js / Bun (server-side)
npm install zenpixESM-only package. Requires
"type": "module"inpackage.json. CommonJS (require) is not supported.
Deno
deno add npm:zenpixOr use the npm: specifier directly:
import { decode, encodeAvif } from "npm:zenpix/deno";Normal use requires
--allow-ffiand--allow-readfor input files. Add--allow-env=ZENPIX_LIBonly when using the optionalZENPIX_LIBoverride.
Browser / Cloudflare Pages (WASM)
npm install zenpix-wasmSee Browser (WASM) for the full guide.
Check installed version
Section titled “Check installed version”# nativenpx zenpix --versionnpm list zenpix
# wasmnpm list zenpix-wasmQuick Start
Section titled “Quick Start”import { decode, resize, encodeAvif } from "zenpix";import { readFileSync, writeFileSync } from "fs";
const image = decode(readFileSync("photo.jpg"));const resized = resize(image, { width: 1920, height: 1080, fit: "cover" });const avif = encodeAvif(resized, { quality: 60, threads: 4 });if (avif) writeFileSync("output.avif", avif);Use convert() as a one-liner pipeline:
import { convert } from "zenpix";import { readFileSync, writeFileSync } from "fs";
const result = convert(readFileSync("photo.jpg"), { resize: { width: 1920, height: 1080, fit: "cover" }, encode: { format: "avif", quality: 60 },});if (result) writeFileSync("output.avif", result);Features
Section titled “Features”| Feature | Description |
|---|---|
| Decode | JPEG / PNG / WebP / AVIF / GIF (first frame) |
| Resize | Scalar two-pass Lanczos-3; fit modes: stretch / contain / cover |
| Encode | WebP / AVIF (configurable threads) / PNG |
| CLI | npx zenpix (batch & stdin/stdout support) |
| RGBA | Background removal, rounded corners, white background compositing |
| Pipeline | convert(): decode → crop → resize → encode in one call |
Reading performance measurements
Section titled “Reading performance measurements”Processing time varies with the CPU, thread count, image characteristics, resolution, and dependency versions. Historical measurements include selected low-core VPS cases where zenpix was faster and macOS or other-image cases where Sharp was faster.
Numbers without redistributable fixtures are not treated as general performance evidence. See Benchmarks for conditions and limitations.