Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Image to Canvas with CORS
var img = document.createElement('img');
img.onload = function(e) {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
var url = canvas.toDataURL(); // Succeeds. Canvas won't be dirty.
img.crossOrigin = 'anonymous';
img.src = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment