const dw = require('digital-watermarking');
const fs = require('fs').promises;
//EnCode Image add digital watermarking
let enCodeFileName = "encode.jpg";
async function DigitalWaterTag(filePath,tag_text) {
let watermarkText = tag_text;
let fontSize = 2;
const img_buffer = await fs.readFile(filePath);
let image = await dw.transformImageBufferWithText(img_buffer,watermarkText,fontSize);
image.write(enCodeFileName, (err, image) => {
if (err) {
console.error('保存图像时出错:', err);
return;
}
console.log('图像保存成功!');
});
}
readImageAsBuffer()
// //DeCode Image get digital watermarking
// let deCodeFileName = "decode.jpg";
// dw.getTextFormImage(enCodeFileName,deCodeFileName);
// console.log("out")