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?
CodePudding user response:
If you want to make white transparent, you need:
... '-flatten', '-transparent', 'white' ...
If you need nearly whites to become transparent as well as pure whites, add some fuzz beforehand:
... '-flatten', '-fuzz', '20%' ...