cropImage is just a special case of cropImageRect, no need to duplicate all the code.
Add simple UnitTest, but it is not yet very meaningful.