If this is for efficiency, then no you cannot get a non-rectangular shape using getImageData() . However, if you want to use the functionality, you can clip like this ( Example JS Lint ):
var img1 = new Image(); img1.onload = function(){ var w = img1.width var h = img1.height ctx.drawImage(img1,0,0);
What you get is the original, and then the cropped version. You can do this every time you upload an image. In addition, you can create an image by creating a second canvas, drawing it, but with a clip. In essence, this creates a cached version of your image, it is still a rectangle, but the clip makes everything outside the clip transparent ( if you like, I can give an example of this, too, see here ).
source share