Skip to content
EN / JA

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.


Node.js / Bun (server-side)

Terminal window
npm install zenpix

ESM-only package. Requires "type": "module" in package.json. CommonJS (require) is not supported.

Deno

Terminal window
deno add npm:zenpix

Or use the npm: specifier directly:

import { decode, encodeAvif } from "npm:zenpix/deno";

Normal use requires --allow-ffi and --allow-read for input files. Add --allow-env=ZENPIX_LIB only when using the optional ZENPIX_LIB override.

Browser / Cloudflare Pages (WASM)

Terminal window
npm install zenpix-wasm

See Browser (WASM) for the full guide.


Terminal window
# native
npx zenpix --version
npm list zenpix
# wasm
npm list zenpix-wasm

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);

FeatureDescription
DecodeJPEG / PNG / WebP / AVIF / GIF (first frame)
ResizeScalar two-pass Lanczos-3; fit modes: stretch / contain / cover
EncodeWebP / AVIF (configurable threads) / PNG
CLInpx zenpix (batch & stdin/stdout support)
RGBABackground removal, rounded corners, white background compositing
Pipelineconvert(): decode → crop → resize → encode in one call

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.