Home:ALL Converter>NodeJS ImageMagick How to convert Image with Transparent background

NodeJS ImageMagick How to convert Image with Transparent background

Ask Time:2021-09-22T05:19:28         Author:Cagrison

Json Formatter

I want to convert my png with white background to transparent background png.

Here is my code.

im.convert(
        [source, '-flatten', '-transparent', path_to],
        function (err, stdout) {
          if (err) {
            reject(err);
          }
          resolve(stdout);
        },
      );

And im getting this error.

Error: Command failed: convert:  `./../uploads/resized_613c98fa-e56e-4a57-ba70-9b1178ad7179.png' @ error/convert.c/ConvertImageCommand/3319.

I'm not able to use 'transparent'. How can i do it?

Author:Cagrison,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275663/nodejs-imagemagick-how-to-convert-image-with-transparent-background
yy