getImageData
is a method on the context
object you retrieve using getContext()
. The canvas element has no such method directly.
var canvas = document.getElementById('flag');
var context = canvas.getContext('2d');
image = context.getImageData();
I've also not seen getImageData
being used without any parameters, and can't find it documentated that this is supported. Normally, you pass 4 parameters specifiying x, y, width, height
; see https://developer.mozilla.org/en-US/docs/HTML/Canvas/Pixel_manipulation_with_canvas