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-reference two-pass Lanczos-3; version 1.0.4 uses NEON / SSE2 for RGBA with scalar fallback; 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.

Published zenpix 1.0.4 uses NEON / SSE2 for RGBA with scalar fallback; its native implementation is unchanged from 1.0.3. All five target jobs built and tested the SIMD and forced-scalar paths, packed their freshly-built binaries, and verified SHA-256 identity, runtime dependencies, and Node.js, Bun, Deno, and CLI execution. The aggregate-verified root and five native optional packages at 1.0.4, plus zenpix-wasm 1.1.2, were published to npm. Registry metadata and integrity were checked for every package, followed by a fresh API / CLI conversion on macOS arm64 and registry-retrieved WASM baseline / SIMD Chromium encoding. Post-publication execution on the other four native targets remains unverified.