var images = require('images'); var path = require('path'); var watermarkImg = images(path.join(__dirname, 'path/to/watermark.ext')); var sourceImg = images(path.join(__dirname, 'path/to/sourceImg.ext')); var savePath = path.join(__dirname, 'path/to/saveImg.jpg');
// 比如放置在右下角,先获取原图的尺寸和水印图片尺寸 var sWidth = sourceImg.width(); var sHeight = sourceImg.height(); var wmWidth = watermarkImg.width(); var wmWidth = watermarkImg.height();