jimp-dev / jimp-dev/jimp

Bitmap manipulation increasing the file size considerably.

Open
#437 14 comments 0 reactions 0 assignees View on GitHub
bug file size issue
Dominant language
TypeScript
Stars
14.7k
Forks
777
PR merge metrics
No merged PRs in 30d

Description

I am using Jimp for a project and this involves manipulating the bitmap by simple bitwise operations. I use a PNG image as a source, and manipulate its bitmap by changing the lower 2-bits every byte, without ever adding any more bytes. What this leads to is that my input is around 86KB but the same bitmap, when written to an image (using the write() method), is coming out to be about 235KB. Is there any way I can avoid this? I would like to have access to same the bitmap which I was manipulating instead of having a new one created (of a much larger size). Are there any options to preserve the original compression, and image size?

Update: I went back and tried reading the same image, and then just writing it back without any manipulation and I am still noticing the size bloat.

This is the function I am using in my workflow:
```
function test(){
Jimp.read("in.png", function (err, image) {
if (err) throw err;
this.write("out.png");
});
}
```

Update 2: It seems the original image had a bit-depth of 8 but the output image has a bit-depth of 32, which explains the bloating. Any way to stop this from happening?

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.