I am finding that a certain code fails in Internet Explorer and Edge, but seems to work flawlessly in Chrome and Firefox:
var image = document.getElementById("myImage"); var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); context.drawImage(image, 1, 0, 499, 278, 0, 0, 749, 417);
img { width: 300px; height: 200px; }
<img id="myImage" src="https://image.ibb.co/bsANfm/emptyphoto.png" /> <canvas id="myCanvas" width="600" height="400"></canvas>
For some reason, the CanvasRenderingContext2D.drawImage() call fails in IE 11 and Edge 40.15063.674.0, where I'm getting an IndexSizeError exception. According to MDN, I should only be getting this error if the size of either the canvas or the source rectangle is 0, which is not the case here.
Could anyone shed some light into whether I'm doing something wrong here, or if there's some workaround available?