let cvs = document.querySelector("canvas");
let ctx = cvs.getContext("2d");
let img = new Image();
img.addEventListener("load", function() {
let cvs2 = document.createElement('canvas');
cvs2.width = 256;
cvs2.height = 256;
ctx2 = cvs2.getContext("2d");
hole(ctx2, 64, 64, 32);
hole(ctx2, 192, 64, 32);
hole(ctx2, 64, 192, 32);
hole(ctx2, 192, 192, 32);
ctx2.globalCompositeOperation = "source-out";
ctx2.drawImage(img, 0, 0, 256, 256);
ctx.shadowOffsetX = 4;
ctx.shadowOffsetY = 4;
ctx.shadowBlur = 8;
ctx.shadowColor = 'black';
ctx.drawImage(cvs2, 0, 0, 256, 256);
});
img.src = "https://placeimg.com/256/256/nature";
function hole(ctx, x, y, r, ccw = false) {
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2, ccw);
ctx.closePath();
ctx.fill();
}
<canvas width="256" height="256"></canvas>