0

When I take a picture in portrait mode everything is fine and looks like this:

enter image description here

in landscape mode it is in the wrong mode and is rotated around 90 degrees. How can I fix that?
Currently, it looks like that in the gallery. It isn't even saved as a landscape picture.

enter image description here

mafioso
  • 1,630
  • 4
  • 25
  • 45

1 Answers1

1

You need to read the orientation from an UIImage like this: image.imageOrientation. And then rotate accordingly.

Luka Jacobowitz
  • 22,795
  • 5
  • 39
  • 57
  • oh thanks and how would it look like for videos? If I use the AVPlayer? – mafioso Aug 02 '16 at 09:01
  • Not sure exactly, maybe refer to this question? :) http://stackoverflow.com/questions/13243847/avfoundation-avplayer-rotation – Luka Jacobowitz Aug 02 '16 at 09:03
  • Doesn't work because I can't set the imageOrientation – mafioso Aug 02 '16 at 09:29
  • If I take a picture in landscape mode the camera stays in portrait mode an so I can see just the picture rotated. How could I rotate it? – mafioso Aug 02 '16 at 09:34
  • Something like this? http://stackoverflow.com/questions/36645060/rotate-uiimage-in-swift – Luka Jacobowitz Aug 02 '16 at 09:36
  • I want to save it as a landscape pic if the device was in landscape mode. Currently the picture is saved as a portrait picture every time. – mafioso Aug 02 '16 at 09:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/118887/discussion-between-mafioso-and-luka-jacobowitz). – mafioso Aug 02 '16 at 09:43