EXIF Autorotate in Drupal

Most photographs nowadays come with some EXIF data, among which an orientation parameter that specifies how the image ought to be rotated to display properly. A lot of websites, browsers and otherwise photo uploading and viewing software support EXIF, but unfortunately Drupal 7 doesn’t in core. So if you upload an image that ought to be rotated and put it through some manipulation like resizing with Image Styles, it will most likely be lying on its side.