1.1.0 • Published 5 years ago
@catdad/to-bmp v1.1.0
@catdad/to-bmp
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-bmpAPI
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.bmpConvert an image (JPG or PNG) from a url to BMP:
npx @catdad/to-bmp https://example.com/input.png > output.bmpYou 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