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?
With Portrait mode, the camera creates a depth-of-field effect, which lets you capture photos with a sharp focus on the subject and a blurred background. Before you get started, make sure that you have the latest version of iOS, and that you have an iPhone that supports Portrait mode.
1 Swipe down from the top-right corner of your screen to open Control Center. 2 Tap the Portrait Orientation Lock button to make sure that it's off. 3 Turn your iPhone sideways.
Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off. Turn your iPhone sideways. If the screen still doesn't rotate, try a different app — like Safari or Messages — which are known to work in landscape mode. Learn how to rotate the screen on your iPad.
How to Determine Camera Orientation on iPhone or iPad Before Taking Photos or Videos Open the Camera app on iPhone or iPad Direct the camera at the subject of the picture or video Pay attention to the options in Camera app, the text of “HDR” and “1x” should be aligned with the orientation you want to snap the photo or video in
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With