1.1.0 • Published 1 year ago

bmp-ts-for-printer v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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