0

On iOS 5 using an iPhone 4s I am trying to pick a photo from the camera roll using UIImagePickerController. The problem I am having is that the image that I pick always has the following attributes (regardless of wether the image is portrait or landscape):

image.size.width = 3264
image.size.height = 2448
image.orientation = UIImageOrientationUp

The UIImage returned from didFinishPickingMediaWithInfo does not seem to give me access to the orientation of the photo.

Is there something a UIImageView uses other than UIImage.UIImageOrientation to specify either a landscape or portrait photo?

Im not using a UIImageView to display the photo so I need to figure out what UIImageView is doing to correct the orientation.

Thanks

Skeep
  • 4,169
  • 2
  • 20
  • 20

3 Answers3

1

Read this: UIImagePickerController Image Orientation

I use the category UIImage+Resize to get the correct orientation after picking the image

Community
  • 1
  • 1
Hanon
  • 3,917
  • 2
  • 25
  • 29
  • Thanks Hanon this has all the answers http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/ – Skeep Mar 07 '12 at 14:31
  • and this! http://eran.sandler.co.il/2011/11/07/uiimage-in-ios-5-orientation-and-resize/ – Skeep Mar 07 '12 at 14:31
0

In my case I was using the CGImage which does not keep the orientation info.

Skeep
  • 4,169
  • 2
  • 20
  • 20
-2

if image.size.width / image.size.height > 1 then it is landsacpe image

if image.size.width / image.size.height < 1 then it is portrait image

Kapil Kumar
  • 104
  • 8
  • Thanks for the reply Kapil that is the problem. Regardless of whether the image is landscape or portrait width is always 3264 and height is always 2448. – Skeep Mar 07 '12 at 10:01
  • Orientation has nothing to do with width and height, and `UIImageOrientation` has eight different values, not just portrait and landscape. – Eran Goldin Dec 10 '15 at 14:18