node.jsimagewatermarkgm

watermark in image using nodejs


I have added watermark on image using node_module 'gm', i had make font color grey but i found an bug in that if image content grey color so my watermark merged with image so i can't read the watermark text, that's why i want to create an overlay between image and watermark text but i don't know how i achieve it my current code is

const image = gm(__dirname+'/download.jpeg').fill('#ffffff').font('Arial', 10, '#ffffff').drawText(10, 20, "some text");
image.write('result.png', err => {
    if(err) return console.error(err);
});

and i don't know how to make overlay between them my actual image is enter image description here

and my watermarked image is enter image description here

any help should be appreciate thanks in advance


Solution

  • So there is no such module that can give you the expected result. But I faced the same problem & came across this module "node-caption" but again this module is also not giving us the expected result. So I have tweaked this module a little bit & made it work as expected. Here is the URL to the modified module of my git hub repo https://github.com/mohsincynexis/node-caption. The changes are only in the generate.js file. Here is the attached image after watermark.enter image description here