How to remove alpha channel in image using Jimp js?

0

I tried to use the code below or .rgba(false) which corrupted the file.

Jimp.read(img).then((image) => {
image.background(0x00000000);
})
javascript
jimp
asked on Stack Overflow May 6, 2020 by Roma

1 Answer

0

Hey I had the same issue, seems like this corrupting issue is already known (see this opened GitHub issue).

One year late someone may have found how to solve it (see this comment).

Please note that I'm not an expert about editing node modules so don't blame me if this is an horrible way to achieve this, I only want to share something I found and that worked for me.

As this comment suggested, I modified in Jimp's png module the index.js file (node_modules/@jimp/png/dist/index.js) the property inputHasAlpha: data._rgba to inputHasAlpha: data.bitmap.alpha and I was able to get a png file without alpha channel as intended.

Hopes this help!

answered on Stack Overflow May 17, 2020 by Draityalan

User contributions licensed under CC BY-SA 3.0