3
votes

I allow the user to upload photos from their photo library or by using their camera.

The issues takes place when the user uploads from the camera. Even though the picture is taken in the portrait mode the image is rotated by 90 degrees CCW (counter clockwise).

When I do a check on the images orientation when I want to display it in an image view it says that the image is already in the .Up position even though it is clearly rotated 90 degrees CCW.

How do I force the image from the camera to be uploaded in the Portrait orientation?

The photos from the photo library upload with the correct orientations. Also I am using a JPEG representation with compression if that is relevant.

1
This should be solved using EXIF information... metapicz.comDavidTaubmann
How did you go about fixing this? I am having the same issueLogan Jahnke
@LoganJahnke It seemed to have just resolved itself, because I haven't had an issue with it for a long time.Taylor Simpson
@LoganJahnke while working on a different project I was trying to figure out why my images were rotated when grabbing them from CoreData. It turns out that you need to save them as a JPEG instead of a PNG. A PNG will not save the orientation data.Taylor Simpson

1 Answers

4
votes

All images taken with the iPhone's camera are in landscape orientation. The fact that the image is to be shown in portrait (rotated CW or CCW) is contained in the JPEG's exif metadata.

Image viewer applications are supposed to use this information and display the image correctly. Not all viewers do this correctly.

The error is on the viewer's side (probably the backend, in your case).

If you can't fix the backend a workaround is to create a new, upright image by decompressing, drawing and recompressing the image. That takes time, memory, battery – and code.