4

I take two photos using the ios`s system camera,which one is in portrait mode and another is in landscape mode, then I use imagePicker to pick them out in my app like this:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

    UIImage* sourceImage = [info objectForKey:UIImagePickerControllerOriginalImage];


    UIImageOrientation imageOrientation = sourceImage.imageOrientation;
    NSLog(@"%d",imageOrientation);

}

Note that I NSLog out the UIImageOrientation value of the image I just picked out. the result is the value for the portrait mode photo is 3(which represents UIImageOrientationRight) and the landscape mode photo is 0 (UIImageOrientationUp) I just do not understand why. can anyone explain that? thanks!

wdanxna
  • 10,699
  • 2
  • 23
  • 24

1 Answers1

3

iPhone's camera save photo regardless to the device orientation but it adds a metainformation to image to allow this image rendered properly. imageOrientation describes the amount of degrees the image should be rotated to be properly rendered.

Max Komarychev
  • 2,836
  • 1
  • 21
  • 32
  • Thanks @Max K.! so the UIImageOrientationRight for portrait photo means the system has to rotate the image CCW 90 degree to render it properly? – wdanxna Jul 29 '13 at 12:00
  • 1
    Yes, please, look at the `UIImage` reference for more information http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImage_Class/Reference/Reference.html. Read carefully to understand what those constants actually mean. – Max Komarychev Jul 29 '13 at 13:38
  • it's incredibly confusing/strange that it seems to save as a landscape?? so the always-default portrait mode is UIImageOrientationRight. I think. – Fattie Mar 09 '14 at 12:09