Photos on Android are always returned in a single orientation on some devices
What is the problem or limitation you are having?
Irrespective of how the camera is oriented while using Android, the returned images are always in the same orientation.
This makes managing the returned photo in a meaningful way more difficult since the orientation may create a negative user experience.
Landscape
Landscape (device rotated 180)
Portrait
Describe the solution you'd like
Provide information about the orientation of the photo. Given Toga just has a file path to an image, this information must be extracted from the image's Exif data.
One better, though...use the orientation information to rotate the image before returning the bitmap to the user. This behavior aligns with iOS behavior.
Android-centric method to rotate image: https://stackoverflow.com/a/31720143/8549606
Describe alternatives you've considered
If users implement the solution in the SO post above, the can workaround this limitation.
It should also be possible to implement a pure Python solution since packages exist to read Exif data from image files and Pillow or similar can rotate images. Although, this does depend on users reading photo.image._path which isn't best.
Additional context
No response
There's two closely related potential features here:
- Ensure that Android gives back an image in the right orientation. This is arguably a bug, not just a feature request, as the behavior of images is (at present) inconsistent between iOS and Android.
- Expose EXIF information on toga.Image. EXIF data is generically useful, not just for resolving orientation issues. If we're going to need to add an EXIF dependency, we might as well make use of it.
I've seen this problem on my Pixel 7 – the image is always oriented as if it was taken in landscape with the "portrait-bottom" of the phone on the right. It makes no difference whether the phone has auto-rotation turned on, or what orientation the Toga app was in before it requested the photo.
However, the problem doesn't occur on an emulator of the same Android version (API level 35). There, the photo is always returned in the correct portrait or landscape orientation, depending on the simulated rotation of the emulator.
Although both devices have the same Android version, their camera apps look quite different, so that may be the cause.