Skip to content

@huh-david/bmp-js

BMP for real-world pipelines.

A pure TypeScript BMP encoder/decoder with fixture-backed behavior, dual ESM/CJS packaging, and a modern release flow.

ts
import { decode, encode } from "@huh-david/bmp-js";
import { readFileSync, writeFileSync } from "node:fs";

const input = readFileSync("./in.bmp");
const decoded = decode(input);

const encoded = encode({
  data: decoded.data,
  width: decoded.width,
  height: decoded.height,
});

writeFileSync("./out.bmp", encoded.data);

Decoded pixel layout is ABGR by default.
Use decode(..., { toRGBA: true }) when your consumer expects RGBA ordering.

Reliable Decoding

Supports 1/4/8/15/16/24/32-bit BMP, plus RLE4/RLE8 decoding with malformed-fixture guardrails.

Flexible Encoding

Writes 1/4/8/16/24/32-bit BMP output, orientation control, and palette-aware paths for indexed formats.

Production Tooling

Strict TypeScript, reproducible releases, CI quality gates, and trusted publishing with provenance.

MIT Licensed