Refactor rotate method.

Allows rotation of non-displayed images.