Here, finally, is the cropResizeRotate() function that is used throughout the patch. I'm not going to add any more commentary.  Let me know if there is anything unclear about this.