Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 views
in Technique[技术] by (71.8m points)

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

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 portrait mode. They gets rotated by 90 degree.

Also other images with portrait mode(not clicked from iPhone) works fine.

Any idea why such happens?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...