I like this utility function for preparing the context. But I don't like the name. Maybe rotateContext or setupRotation or something?  The name "rotateImage" makes it sound like it is actually doing the rotation.