https://github.com/catdad-experiments/to-bmp
🍦 encode jpg and png images to bmp
https://github.com/catdad-experiments/to-bmp
bmp encoder jpg nsis png
Last synced: 4 days ago
JSON representation
🍦 encode jpg and png images to bmp
- Host: GitHub
- URL: https://github.com/catdad-experiments/to-bmp
- Owner: catdad-experiments
- License: mit
- Created: 2020-09-30T21:57:43.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-29T05:08:36.000Z (over 4 years ago)
- Last Synced: 2025-03-17T20:59:01.892Z (7 months ago)
- Topics: bmp, encoder, jpg, nsis, png
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @catdad/to-bmp
[![Build Status][travis.svg]][travis.link] [![NPM Downloads][npm-downloads.svg]][npm.link] [![NPM Version][npm-version.svg]][npm.link]
[travis.svg]: https://travis-ci.com/catdad-experiments/to-bmp.svg?branch=master
[travis.link]: https://travis-ci.com/catdad-experiments/to-bmp
[npm-downloads.svg]: https://img.shields.io/npm/dm/@catdad/to-bmp.svg
[npm.link]: https://www.npmjs.com/package/@catdad/to-bmp
[npm-version.svg]: https://img.shields.io/npm/v/@catdad/to-bmp.svg> 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](https://github.com/electron-userland/electron-builder/issues/2548), 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`](https://github.com/wokwi/bmp-ts).
## Install
```bash
npm install @catdad/to-bmp
```## API
```javascript
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:
```bash
npx @catdad/to-bmp < input.jpg > output.bmp
```Convert an image (JPG or PNG) from a url to BMP:
```bash
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`](https://github.com/wokwi/bmp-ts) - the original code that the encoder here is based on