(bug 30640; follow-up r92279) Rotating images was making skewed images
This is Bryan's patch from bug 30640 with a couple minor related changes, plus some unit tests.
This also addresses an issue with preventing too-big images from being scaled from r92279.
I also noticed that image magick's rotation support is broken in 6.3.7 (the version I had installed locally. I've since upgraded) I'm not sure if we should be doing something about that...
I did test this without both image magick, and gd (although only very briefly with gd) both seemed to work well. I didn't test any other image scalars.