JSPM

bmp-ts-for-printer

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25636F
  • License MIT

A pure typescript BMP encoder and decoder

Package Exports

  • bmp-ts-for-printer
  • bmp-ts-for-printer/package.json

Readme

bmp-ts-for-printer

A pure typescript bmp encoder and decoder.

Codecov code style: prettier

Supports decoding and encoding in all bit depths (1, 4, 8, 16, 24, 32).

本仓库fork自bmp-ts, 兼容了某些打印机打印深度为1的bmp格式的图片时,打印效果为反色的问题
This repository is forked from bmp-ts, and it addresses the issue where some printers print 1-bit BMP images in inverted colors.

Install

npm install bmp-ts-for-printer

Usage

Example: convert image to 1 bit

const bmp = require('bmp-ts-for-printer');
const Jimp = require('jimp');
const fs = require('fs');

const image = await Jimp.read("./a.bmp");

const buffer = await image
    .getBufferAsync(Jimp.MIME_BMP);
const bitmap = bmp.decode(buffer);
bitmap.bitPP = 1;

const { data } = bmp.encode(bitmap);

fs.writeFileSync('./output.bmp', data);