Skip to content

Instantly share code, notes, and snippets.

@brianfoody
Created September 20, 2018 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianfoody/968a6b10f29772126105fe82e888d504 to your computer and use it in GitHub Desktop.
Save brianfoody/968a6b10f29772126105fe82e888d504 to your computer and use it in GitHub Desktop.
const gm = require('gm').subClass({ imageMagick: true }); // Enable ImageMagick integration.
gm()
.command("convert")
.in(imageIn)
.borderColor("white")
.border(1, 1)
.fill("none")
.fuzz(`${fuzz}%`)
.draw("matte 1,1 floodfill")
.shave(1, 1)
.matte()
.write(`/tmp/${randomFileName}transparent.png`, function(err, bufferOut) {
if (err) {
callback(err);
} else {
callback(null, `/tmp/${randomFileName}transparent.png`, randomFileName);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment