我想创建一张礼品卡来发送许多带有不同文本的电子邮件,我正在使用下面的逻辑来打印它的工作,但用生成的前一张图像覆盖。
Jimp.read(fileName)
.then(function (image) {
loadedImage1 = image;
return Jimp.loadFont(Jimp.FONT_SANS_16_BLACK);
})
.then(font => {
console.log('[][][', emailData);
var paths = [];
for(let i=0; i< Object.keys(emailData['recipient']).length; i++){
var receipentName = "Hello "+emailData['recipient'][i].name+', ';
loadedImages[i]= Object.assign(loadedImage1);
loadedImages[i].print(font, 220, 400, header, 500);
loadedImages[i].print(font, 220, 440, venue, 500);
loadedImages[i].print(font, 220, 460, location, 500);
loadedImages[i].print(font, 220, 520, receipentName, 500);
loadedImages[i].print(font, 220, 580, message, 500);
//loadedImage.print(font, 10, 30, imageCaption);
var path= basePath + '/invitation/' + bookingId + '/' + bookingId+i + '.jpg';
//let fullPath = config.BASE_URL + '/uploads/invitation/' + bookingId + '/' + bookingId+i + '.jpg';
paths[i] = path;
loadedImages[i].write(path);
}
res.status(200).json({
data: {
paths: paths,
path: path, //config.BASE_URL + '/uploads/invitation/' + bookingId + '/' + bookingId + '.jpg',
bookingData: detail,
restaurantDetails: restaurantDetails
},
status: 1,
msg: "Notes data"
});
})
.catch(function (err) {
console.error(err);
});