See http://jsfiddle.net/jdb1991/6sxke/
I’ve got a canvas element that doesn’t know what it’s going to be used for until an image has loaded, so I need to be able to change the dimensions of the element on the fly, after creating the image object.
Something is going wrong though, as it seems to be running the commands asynchronously; writing the image to the context before the resize occurs.
use:
demo: http://jsfiddle.net/ycjCe/1/
source: https://developer.mozilla.org/en-US/docs/Canvas_tutorial/Basic_usage