Skip to content

Instantly share code, notes, and snippets.

@EtherDream
Created September 7, 2017 09:30
Show Gist options
  • Save EtherDream/3c2dbd0c441c7f1f0d42eec9ebac4344 to your computer and use it in GitHub Desktop.
Save EtherDream/3c2dbd0c441c7f1f0d42eec9ebac4344 to your computer and use it in GitHub Desktop.
var URL = 'http://gd1.alicdn.com/imgextra/i1/394695430/TB2d4w3cXXXXXc4XXXXXXXXXXXX_!!394695430.jpg';
var img = new Image();
img.onload = function() {
var c = document.createElement('canvas');
var w = c.width = img.width;
var h = c.height = img.height;
ctx = c.getContext('2d');
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, w, h);
console.log(data);
};
img.src = URL;
img.crossOrigin = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment