image clicked from iPhone in Portrait mode gets rotated by 90 degree

后端 未结 3 1162
逝去的感伤
逝去的感伤 2020-12-09 07:19

I am uploading an image clicked from iphone both in landscape and portrait mode. The image with landscape mode is uploaded fine but the issue is with the image uploaded with

3条回答
  •  醉话见心
    2020-12-09 07:54

    In your delegate:

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

    After you get your UIImage from "info" dictionary for the key "UIImagePickerControllerOriginalImage" ,You can see the image orientation by imageOrientation property. If is not like you want just rotate your image before you upload it.

    imageOrientation
    The orientation of the receiver’s image. (read-only)
    
    @property(nonatomic, readonly) UIImageOrientation imageOrientation
    Discussion
    Image orientation affects the way the image data is displayed when drawn. By default, images are displayed in the “up” orientation. If the image has associated metadata (such as EXIF information), however, this property contains the orientation indicated by that metadata. For a list of possible values for this property, see “UIImageOrientation.”
    
    Availability
    Available in iOS 2.0 and later.
    Declared In
    UIImage.h 
    

    UIImage Class Reference

    UIImagePickerController Class Reference

    UIImagePickerControllerDelegate Protocol Reference

    Second option:

    Is to allow user to edit your image and get the image for "UIImagePickerControllerEditedImage";

    Set your UIImagePickerController "allowsEditing" property to Yes.

    In your delegate just get from the "info" dictionary the UIImage for the "UIImagePickerControllerEditedImage" key.

    Good luck.

提交回复
热议问题