1

I'm getting inconsistent results depending on whether I get the image directly from the camera in the callback or choosing it from the camera roll.

In the UIImagePickerControllerDelegate callback method, the UIImage.imageOrientation comes up as UIImageOrientationRight no matter how the photo is taken.

When reading it off the Camera Roll, a landscape shot (turned left) comes up UIImageOrientationUp while a portrait shot comes up UIImageOrientationRight.

How can I reliably get the camera orientation in both situations?

Kampai
  • 22,848
  • 21
  • 95
  • 95
Stephen Petschulat
  • 1,159
  • 2
  • 14
  • 23
  • I found this somewhat related link http://mohrt.blogspot.com/2009/05/camera-image-orientation.html and am aware of the scaleAndRotateImage code http://blog.logichigh.com/2008/06/05/uiimage-fix/ ... but neither explain why I might be getting incorrect imageOrientation information directly off of the image passed in from the callback. – Stephen Petschulat May 25 '09 at 04:25
  • I'm having the same issue. For instance imageOrientation is 3(UIImageOrientationRight,90 deg CW, according to apple docs) when I have the iphone in the upright position and it's 0(UIImageOrientationUp) when it's turned left(should be UIImageOrientationRight I believe). Have you found any solution? – Brenden Aug 13 '09 at 20:52
  • I haven't found a solution, but I've been meaning to check of OS 3.0 fixes this. – Stephen Petschulat Aug 17 '09 at 20:39
  • Add me to those afflicted: https://devforums.apple.com/thread/69393?tstart=0 – Adam Jack Sep 23 '10 at 00:16
  • It is also worth noting that the behavior is different on different devices (iPod vs iPhone4) and os versions 4.0, 4.1, etc. On our App we had to special case a bunch of combinations to get full coverage. – Brad The App Guy Oct 04 '10 at 19:51

3 Answers3

3

I posted this to the Apple forums, and got the explanation:

"The camera is actually landscape native, so you get up or down when you take a picture in landscape and left or right when you take a picture in portrait (depending on how you hold the device)."

See:

https://devforums.apple.com/message/301160#301160

Thanks:

https://devforums.apple.com/people/Rincewind

Adam Jack
  • 590
  • 5
  • 17
0

I have tried the imageOrientation property after the picture has been taken, it's funny because I have the orientation values messed up. Up is Left, Down is Right, Left is Down and Right is Up, for example, if I hold the iPhone "Up" (the normal position) then imageOrientation is "UIImageOrientationRight".

- (void)imagePickerController:(UIImagePickerController *)picker
  didFinishPickingImage:(UIImage *)image
      editingInfo:(NSDictionary *)editingInfo {
    switch (image.imageOrientation) {
      case UIImageOrientationUp: //Left
       break;
      case UIImageOrientationDown: //Right
       break;
      case UIImageOrientationLeft: //Down
       break;
      case UIImageOrientationRight: //Up
       break;
      default:
       break;
     }
}

Currently I am using 4.1 SDK GM (xcode_3.2.4_and_ios_sdk_4.1_gm_seed) targeting for iOS 3.1

LightMan
  • 3,517
  • 31
  • 31
-1

I have read somewhere that the UIImagePickerController doesn't turn on listening to hardware orientation events, so you may need to call

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

before you capture images in your own app. I'm about to go try testing this myself, so I hope it works!

David Maymudes
  • 5,664
  • 31
  • 34