When I take a picture with Androids camera app, it detects the phone's orientation and saves the pic accordingly. So if i take a picture of a building, the roof will be on the topside, whether I hold the phone in landscape position or portrait.
However, when i use
Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
to get a picture, the camera app doesn't react to orientation. If i hold the phone vertically (portrait), the resulting pic will be rotated, with said building's roof to the left of the screen.
How can I set the intent so that the camera will take orientation into account?
Or can I deduce in some way in what orientation the pic was taken and rotate it myself afterward?
Or any other suggestion will be greatly appreciated.
~Thanks in advance, best regards.
Found the answer. The exif of the image has an indicator of the orientation. Just in case, exif can be viewed in Android like this:
I used a file provider and nothing worked except making a temporary copy and reading the data from it.
bonus rotate function
Read from Exif if available, otherwise read from MediaStore
For a quick fix you can check if image's width is bigger than image's height. it means it's landscape and you can change it to portrait.