I am trying to put a watermark on an image, using image-watermark, nodejs.
const express = require('express')
const app = express();
var path = require('path');
var watermark = require('image-watermark');
app.use(express.static(path.join(__dirname, 'public')));
var options = {
'text' : 'sample watermark',
'resize' : '200%'
};
app.get('/', function (req, res) {
var fs = require('fs');
if (fs.existsSync('./public/files/pg363.jpg')) {
// Do something
watermark.embedWatermark('./public/files/pg363.jpg', options);
res.send('Hello world');
}else{
res.json({"filesexist":"no"});
}
});
app.listen(3000,function(){
console.log('App running on server 3000');
})
This is giving me error:
events.js:163
throw er; // Unhandled 'error' event
^
Error: spawn identify ENOENT
at exports._errnoException (util.js:1050:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
is this error related to filepath. my directory structure is pdf-watermark(home directory)-> public-> files-> pg363.jpg
Please help.