Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

image

iphone

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?

like image 492
Suresh Varma Avatar asked May 12 '11 03:05

Suresh Varma


People also ask

What is portrait mode on iPhone?

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.

How do I Turn Off portrait orientation on my iPhone?

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.

How do I rotate the screen on my iPhone?

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?

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


1 Answers

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.

like image 153
Alex Terente Avatar answered Sep 28 '22 06:09

Alex Terente