JSFiddle - React, Tailwind, and code Playground

by Rob Crowther

HTML

<canvas id="mycanvas" width="600" height="600"></canvas>

JavaScript

var c = document.getElementById('mycanvas');
var ctx = c.getContext('2d');
var img = new Image();
img.onload = function () {
  ctx.drawImage(img, 0, 0, 300, 200); // resizes image to 300px wide, 200px high
  ctx.drawImage(img, 300, 0, 300, img.height * (300/img.width));
}
img.src = 'http://sanjaal.com/imagehost/image-B340_4AC0ECE3.jpg';