Working with Apple's iOS image orientation
Using PHP and ImageMagick
You might notice pictures taken with an iOS device (iPhone or iPad) look like they are not rotated properly when transferring them to another device or software. This happens because the device is held at a certain angle when the picture is taken and it’s up to the software at the receiving end to display it however it wants.
Apple’s camera will write orientation info into the exif headers of images taken and you can rotate it accordingly.
Here is an example of rotating an image using PHP with the ImageMagick library;