Dynamic Watermark is npm watermark module to add watermark over image. It can add image as well as text watermark on given positions. It does great job for adding watermarks.
npm install dynamic-watermark --save
After successful installation of dynamic-watermark follow below steps:
var watermark = require('dynamic-watermark');
var optionsImageWatermark = {
type: "image",
source: "a.png",
logo: "logo.png", // This is optional if you have provided text Watermark
destination: "output.png",
position: {
logoX : 200,
logoY : 200,
logoHeight: 200,
logoWidth: 200
}
};
var optionsTextWatermark = {
type: "text",
text: "Watermark text", // This is optional if you have provided text Watermark
destination: "output.png",
source: "a.png",
position: {
logoX : 200,
logoY : 200,
logoHeight: 200,
logoWidth: 200
},
textOption: {
fontSize: 100, //In px default : 20
color: '#AAF122' // Text color in hex default: #000000
}
};
//optionsImageWatermark or optionsTextWatermark
watermark.embed(optionsImageWatermark, function(status) {
//Do what you want to do here
console.log(status);
});