JSFiddle - React, Tailwind, and code Playground

by Emmanuel Garcia

HTML

<img id="thing" src="https://drive.google.com/uc?id=1OoHataGaYBzux2OlPsmWW1st4BoLBPrV">
<img id="result">

JavaScript

function getBase64Image(img) {
  var canvas = document.createElement("canvas");
  canvas.width = img.width;
  canvas.height = img.height;
  var ctx = canvas.getContext("2d");
  ctx.drawImage(img, 0, 0);
  return canvas.toDataURL("image/png");
}

img = document.getElementById('thing');
img.onload = function() {
  res = getBase64Image(img);
  document.getElementById('result').src = res;
};