This is a big patch, but more than 1/3rd of it is this file of unit tests.  If I've got time today, I may add some more tests.
Travis seems broken today, but these tests do work locally for me.

The key to understanding these tests is the image created in suiteSetup() below. Each pixel encodes its own x,y coordinates.  So when we crop, resize, or rotate the image, we can inspect the pixels of the returned image to see if they came from the right parts of the image.

Here's what the image looks like as a png:
![magic](https://cloud.githubusercontent.com/assets/516914/2793852/3da6f3f0-cbe5-11e3-8c9c-07756c63d0b3.png)