I am using graphicsmagick npm:
https://www.npmjs.com/package/gmI am trying to write a code like the following.
I am trying to make this work with stream ...
myimg.png is an image with white background.
I want to change the white background to transparent as stated in the npm docs using -transparent.
const gm = require('gm');
const fs = require('fs');
// ....
function makeTransparent(){
const readStream = fs.createStream("myimg.png");
gm(readStream)
.transparent("#FFFFFF")
.stream(function, err, stdout, stderr) {
const writeStream = fs.createWriteStream("result.png");
stdout.pipe(writeStream);
});
}
What am I doing wrong here?