var cnv = document.getElementById('canvas');
var ctx = cnv.getContext('2d');
ctx.width = ctx.width; // Clear the context
// Load an image
var flag = new Image();
flag.src = 'http://blog.burlock.org/files/html5/saflag.png'
// Draw the full image.
ctx.drawImage(flag, 60, 20);
// Shrink the image down to half the size.
ctx.drawImage(flag, 60, 140, 100, 50);
// Draw only the piping shrike (bird) part of the flag.
ctx.drawImage(flag, 125, 25, 50, 50, 60, 210, 50, 50);