I am trying to convert any file to a PNG with transparency if the original file has transparency, of course. This works with a transparent PNG but I can't get it to work with with a PDF, AI, or PSD file. Everything just converts with a white background. I have scoured the internet looking for a solution with no luck. Any help is appreciated!
const im = gm.subClass({ imageMagick: '7+' });
im(f.filepath)
.background('none')
.write(`public/upload/${f.newFilename}.png`, (err) => {
if (err) {
console.error('Error converting file:', err);
} else {
console.log('File converted successfully!');
}
});
I was not able to reproduce your problem.
I was able to create a PNG file with transparent background from a PDF file (with transparent background) using your snippet.
Versions:
The code:
So either the problem is with the input files or the versions that you are using.