Bitmap manipulation increasing the file size considerably.
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14
Top GitHub Comments
I’m running into the same issue when reading in an image from Base64-encoded data and writing it back out without any manipulation. Doing so results in a file twice the size of the original.
how about jpeg ? when I write image to buffer , it increasing the file size 168kb > 800kb ? how can fix ?