UIImagePickerController does not appear to report correct orientation of the image re
I am using the UIImagePickerController to capture a picture from the camera. I then scale and rotate the image using code that I has been posted repeatedly on various SDK forums. The problem appears that the UIImage returned to the UIImagePickerController's delegate is reporting the wrong orientation. Has anyone seen this issue before and if so, do you have any suggestions or solutions?
Here is the delegate's method to get the returned image. The UIImage passed into this method does not have the correct orientation.
What do you mean "does not have the correct orientation"? How are you determining what the correct orientation is?
Note that when you display a UIImage in a UIImageView, it will take the orientation into account, but when you draw the same image using core graphics, you have to do the orientation transformation yourself (which is what scaleAndRotateImage does for you).
Pictures returned from the camera always have a left(?) orientation. Put them in a UIIMageView and you would never know that, but it is "correct".
The orientation I am referring to is in the UIImage sent by the UIImagePickerController. It has a imageOrientation property and when I interrogate the value, it does not match the orientation that I took the photo in.
For example, if I have the device up (UIImageOrientationUp), the orientation returned by the this image is UIImageOrientationRight. Similar problems occur when taking pictures in left or right landscape.
You are assuming that the orientation of the CCD matches the orientation of the phone. I'm betting that they had to turn it 90 degrees to wedge it in.
Regardless, the return value may not be what you expect, but it isn't wrong. When the phone is held vertically, the bits from the camera image are all rotated to the right, and orientation is set as right. Any rotation of the phone will return the proper bits and orientation in the image.
UIImageVIews take this orientation into account when drawing, so again, everything is consistent.