Answer the question
In order to leave comments, you need to log in
How to change background color in GraphicsMagick for node.js?
When converting a png image to jpg, the entire transparent background turns black (what an idiot). I searched Google for such a problem, everyone works with the image through the shell console, but I couldn’t find any solution through the module in npm .. Maybe someone knows how to deal with this?
Or can someone suggest an alternative solution? Just pictures before uploading in any case, you need to effectively compress
gm('./upload/'+file.name)
.quality(cfg.quality)
.background('white')
.write("./public/images/"+rand+'.jpg', function (err) {
fs.unlink('./upload/'+file.name, function(error){
if (error) res.end('Не удается работать с файлом');
});
if (err) {
res.end('Ошибка при загрузке изображения!');
} else {
console.log('Done!');
res.end(rand+'.jpg');
}
});
.background('#FFF')
.mosaic()
.matte()
Answer the question
In order to leave comments, you need to log in
When converting a png image to jpg, the entire transparent background turns black (what an idiot)
gm(image).background("#FFF").stream("jpeg", cb);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question