Usage no npm install needed!

<script type="module">
  import catdadToBmp from 'https://cdn.skypack.dev/@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.


npm install @catdad/to-bmp


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


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.


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