jimp-dev / jimp-dev/jimp

Need to encode to 1-bit BMP

Open
#633 9 comments 2 reactions 0 assignees View on GitHub
issue-in-dependency
Dominant language
TypeScript
Stars
14.7k
Forks
777
PR merge metrics
No merged PRs in 30d

Description

**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:

```javascript
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](https://user-images.githubusercontent.com/882424/46117170-80cfe500-c19b-11e8-98b2-64ac7c062684.jpeg)

![gimp-lion](https://user-images.githubusercontent.com/882424/46117238-cee4e880-c19b-11e8-9fa4-5bbb0433ba5b.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.