Objective-c – iPhone camera pics come up rotated — CGAffineTransformInvert: singular matrix


I'm getting the UIImage from the image picker and putting it into a UIImageView. It works fine for regular images, but for images taken with the iphone camera, they sometimes come up rotated 90 degrees.

When accessing one of those images later (it has already been saved to disk) I noticed the above error.

Any ideas? I assume it has something to do with the iphone storing extra exif metadata about the camera position while the photo was taken, however one of the pictures was taken in portrait mode and somehow got rotated to landscape.

Best Solution

The solution I've used is to rotate & flip the image as dictated by the imageOrientation property. There is some code here that will do the trick: UIImage fix.

A UIImageView rotates & flips automatically, so it's not a problem if all you do is display it on screen like that.