Fixing photo orientation on images uploaded via PHP from iOS devices

Below is a great function (created by Wes over on Stack Overflow) that can be used to automatically correct the image orientation when uploading images (the main culprit for weird orientation related glitches being iOS based devices) - simple call the correctImageOrientation() function after uploading the image and voilla the rotation/orientation of the image is corrected!

Source