Rotating iOS Photo Correctly using CodeIgniter’s Image_lib

I have an issue with iOS Photo recently not being displayed properly after uploading. After googling around, I’ve managed to found a workaround for this issue.

Imagine this scenario: You have a working website with file uploader and then strange phenomenon happens when you upload a photo from iPhone in portrait. The photo is uploaded properly, but the orientation is landscape.

What is the problem with iOS Photo?

The problem was that image rotation was added to the photo as EXIF data not used by most browsers. If you’re using CodeIgniter, you can use CodeIgniter’s Image_lib library to help you fix this.

Solving the Rotation Issue with CodeIgniter Image_lib

Open your controller file or the file where you handle the image after upload. Add the below code to rotate the image and replace it in the same file destination.

Please note that you might have different requirements hence need to change any parts of the code to your needs.

Now all images from iOS devices (iPhone and iPad) should display properly.

Leave a reply:

Your email address will not be published.