iphoneiosipaduiimageuiimageorientation

Correcting orientation of UIImage stored in document with lost EXIF tags


I have encountered a similar problem to others on SO regarding the orientation of UIImages taken using the iPad camera. Essentially, I am taking a UIImage using the camera on the iPad. When I then display it, it has rotated through 90 degrees.

From reading other questions and answers, I now understand that when the camera takes a photo it stores an EXIF tag which determines the orientation of the photo. This would normally allow all Mac and iOS apps to read this orientation data. However, I am storing my images in the documents directory as NSData (having been converted through UIImagePNGRepresentation and saving the URL in core data. I am assuming the process of doing this is causing me to lose the orientation EXIF tag so when it is retrieved it is displayed incorrectly.

Can anyone think of a way to correct this?

Thoughts, advice and pointers all welcome.

Many thanks


Solution

  • EXIF metadata is not accurate in orientation it is accurate in GPS data, it will detect only 90 & 180 & 270 with some Error cases try this

    iOS UIImagePickerController result image orientation after upload

    Good Luck