question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to encode to 1-bit BMP

See original GitHub issue

Is your feature request related to a problem? Please describe. I have web service that receives PNG/JPEG and converts them into BMPs. The generated BMP is then requested by a low-powered microcontroller (esp8266) and then displayed in a small B&W 2.7 inch E-Ink display. The microcontroller has some issues with timeouts when image sizes are “large”.

Describe the solution you’d like I would like the option to encode as a 1-bit BMP output. Currently, If I read a 58Kb JPEG image the BMP output (with resizing as well as removing color) comes out as a 143Kb. If I use gimp to convert to 1-bit indexed color the result is 7Kb!

Adding a . bitPP - Bits per pixel option where I can set to 1 to encode will be ideal.

Describe alternatives you’ve considered Here is the code I’m using:

const fs = require('fs');
const Jimp = require('jimp');

test();

async function test() {
    const image = await Jimp.read('lion.jpeg');

    await image
      .contain(264, 176, Jimp.HORIZONTAL_ALIGN_CENTER | Jimp.VERTICAL_ALIGN_MIDDLE)
      .greyscale()
      .contrast(0.8)
      .dither565()
      .deflateStrategy(0)
      .filterType(Jimp.PNG_FILTER_NONE)
      .colorType(0)
      .background(0xFFFFFFFF)
      .rotate(90)
      .writeAsync('lion.bmp');

    const orig = fs.statSync('lion.jpeg');
    const result = fs.statSync('lion.bmp');

    console.log(`${orig.size / 1000.0}kb`, `${result.size / 1000.0}kb`);
}

Additional context lion

gimp-lion

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

2reactions
hipstersmoothiecommented, Oct 1, 2019

It’s actually published now. Haven’t found time to integrate it into jimp

https://github.com/hipstersmoothie/bmp-ts

0reactions
rlightnercommented, Oct 1, 2019

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to convert a PNG to 1-bit BMP - image - Stack Overflow
If you want a 1-bit depth for the whole image (i.e. binary), then do convert image.png -depth 1 -type bilevel BMP3:result2.bmp.
Read more >
BMP Converter, convert any images, eg PNG to BMP or JPG ...
Convert PNG to BMP, JPG to BMP or any images formats. 1, 4, 8, 16, 24 or 32 bits image converter. Support for...
Read more >
Bits to Bitmaps: A simple walkthrough of BMP Image Format
My first thought was to; understand how BMP encoding works, ... Monochromatic images have 1-bit color depth because a pixel can be true...
Read more >
Best way to compress 1-Bit Bitmap - Google Groups
microcontroller (limited memory) ... so even a 1 bit bitmap needs to be ... only type of compression I can think of is...
Read more >
How to Convert an Image to Monochrome Bitmap
Single color graphics can be converted to Monochrome Bitmap. This takes all color values in the image and converts them to straight black....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found