@catdad/to-bmp

1.1.0 • Public • Published

@catdad/to-bmp

Build Status NPM Downloads NPM Version

Convert JPG or PNG images to BMP

This module was specifically created to generate BMP images that are compatible with NSIS in order to create splash images for Electron portable applications, when I discovered that various popular encoders did not produce images that could be used within NSIS. The encoder in this module is based on @wokwi/bmp-ts.

Install

npm install @catdad/to-bmp

API

const { promises: fs } = require('fs');
const toBmp = require('@catdad/to-bmp');

(async () => {
  const jpeg = await fs.readFile('./path/to/my.jpg');
  const output = await toBmp(jpeg);

  await fs.writeFile('./path/to/my.bmp', output);
})();

CLI

Convert a local image (JPG or PNG) to BMP:

npx @catdad/to-bmp < input.jpg > output.bmp

Convert an image (JPG or PNG) from a url to BMP:

npx @catdad/to-bmp https://example.com/input.png > output.bmp

You can use these to generate the splash image for your Electorn app directly in a postinstall or prepackage script.

Related

  • @wokwi/bmp-ts - the original code that the encoder here is based on

Package Sidebar

Install

npm i @catdad/to-bmp

Weekly Downloads

7

Version

1.1.0

License

MIT

Unpacked Size

13.5 kB

Total Files

7

Last publish

Collaborators

  • catdad