Create new image with transparent colour in jimp (js library) in Nodejs

2

I am using jimp to manipulate the image. Everything is working fine but when I am creating a new image with

new Jimp(256, 256, (err, image) => {
  // this image is 256 x 256, every pixel is set to 0x00000000
});

every pixel is set to 0x00000000

I need no background color image (it need to be transparent), How can I achieve this?

Edit : when I am sending a png image then it is giving me a transparent image,when the third argument is not passed when the third argument is not passed. And jpeg is giving me black. And I am also manipulating image before sending or showing

Thanks for help.

javascript
node.js
image
image-manipulation
asked on Stack Overflow Jul 31, 2019 by ashad • edited Jul 31, 2019 by ashad

1 Answer

1

You should try this, as the last 2 digits of the color represent the alpha channel:

Or you can use a css color format:

new Jimp(256, 256, '#000000ff', (err, image) => {

});

As explained here:

https://www.npmjs.com/package/jimp#creating-new-images

answered on Stack Overflow Jul 31, 2019 by Emanuele

User contributions licensed under CC BY-SA 3.0