Question

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

Was it helpful?

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

OTHER TIPS

EXIF is something that is in image files, not UIImage. When you take a photo with the camera, UIImagePicker never saves it in a file, therefore, there is no EXIF yet.

In your case though, the problem isn't the orientation of the iPad. I believe UIImagePNGRepresentation always saves it rotated 90 degrees (regardless of rotation). You just need to rotate it before generating a PNG. I don't know why it does this, but you just need to work around it.

Take a look at this library: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/ He has the code to take an image and remove the orientation info by transforming it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top