<div class="example">
  <p>Click the image to copy:</p>
  <p>
    <img src="https://assets.codepen.io/74045/house.png" alt="a house" title="click to copy" />
  </p>

  <p>If this doesn't work for you <a href="https://codepen.io/pen/debug/XWLqXqe" target="_blank">try Debug Mode</a>.</p>
</div>
body {
  height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background: #455a64;
  font-family: monospace;
}

.example {
  background: white;
  border-radius: 12px;
  overflow: clip;
  width: 75dvi;
}

p {
  text-align: center;
  padding-inline: 1rem;
}
document.querySelector("img").addEventListener("click", copyImagetoCB);

async function copyImagetoCB(e) {
  // should be dynamic
  let type = "image/png";
  let dataReq = await fetch(e.target.src);
  let data = await dataReq.blob();

  let blob = new Blob([data], { type });

  let cbData = [new ClipboardItem({ [type]: blob })];
  await navigator.clipboard.write(cbData);

  console.log("Done");
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.