Restructured the Exif orientation handling.

* Moved logic into a resize() util function that wraps
  PIL.Image.resize().
* Added and utilized a couple utility functions for getting
  image dimensions, taking orientation into account.