Yes, you canvas needs to be sized so the rotated image fits inside it.
One way of doing this is finding the bounds like this:
function getBounds(w, h, radians){
var a = Math.abs(Math.cos(radians)),
b = Math.abs(Math.sin(radians));
return {h: h * a + w * b,
w: h * b + w * a}
}
Now you will have the bounds or size you need for the canvas for the image to fit inside at that specific angle. I have written a little more about finding bounds in this article including finding max bound for any angle.