Add Watermark to Images From The Browser

We start by drawing the image into a canvas. To do this, we need to make sure the image has been loaded by the browser, which we can do with this function: 1 2 3 4 5 6 7 8 async function loadImage(url) { return new Promise((resolve, reject) => { const img = new Image(); img.onload = () => resolve(img); img.onerror = reject; img.src = url; }); }