import sharp from "sharp"; const maskPath = "data/media/assets/9a/9a2d060c5d49f72fda4d97c25ff4639acc850724758f43f1783218e533585b4a.mask.png"; const master = "data/media/assets/9a/9a2d060c5d49f72fda4d97c25ff4639acc850724758f43f1783218e533585b4a.png"; const mw = 1200; const m = await sharp(maskPath).metadata(); const mh = Math.round(mw*(m.height!/m.width!)); const maskRes = await sharp(maskPath).resize(mw,mh).raw().toBuffer(); const rgb = await sharp(master).resize(mw,mh).raw().toBuffer({resolveWithObject:true}); const out = Buffer.from(rgb.data); for (let i=0;i=128) { out[i*3]=Math.min(255,Math.round(out[i*3]*0.55+115)); out[i*3+1]=Math.round(out[i*3+1]*0.55); out[i*3+2]=Math.round(out[i*3+2]*0.55); } } await sharp(out,{raw:{width:mw,height:mh,channels:3}}).png().toFile("tmp/mask-overlay2.png"); console.log("ok");