You can use setTransform
The first two numbers are the direction and length (scale) of the x axis, the next two are the direction and length of the y axis and the last two are the location of the origin.
The quickest way to set translation, scale, and rotation
var scale = ?
var originX = ?
var originY = ?
var rotation = ?
ctx.setTransform(scale,0,0,scale,originX,originY);
ctx.rotate(rotation);
or you can set the rotation in the setTransform by calculating the axis directions
var scale = ?
var originX = ?
var originY = ?
var rotation = ?
// get the x axis direction and length
var xdx = Math.cos(rotation) * scale;
var xdy = Math.sin(rotation) * scale;
// if you are not skewing then the y axis is at 90deg so x is neg y and y is x
ctx.setTransform(xdx,xdy,-xdy,xdx,originX,originY);
Then if you need to restore to the default transform
ctx.setTransform(1,0,0,1,0,0); // restore default transform
All the values for setTransform are in pixels and set transform basically describes where and what shape the renderer will create the pixel at 0,0
Smoothing out the pan and zoom.
This answer goes into more depth and gives a working example of using the mouse to scale and zoom a image using the mouse via setTransform (no need to use save restore) It also shows how to smooth the zoom and pan Pan and Zoom