Alex Rivera | Logout

How can I find the orientation of a picture taken with Intent MediaStore.ACTION_IMAGE_CAPTURE?

Asked 2010-02-17T22:21:27.337
21

When I take a picture with Android's camera app, it detects the phone's orientation and saves the picture 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 the orientation. If I hold the phone vertically (portrait), the resulting picture 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 the orientation into account?

Or can I deduce in some way in what orientation the picture was taken and rotate it myself afterwards?

Or is there another way?

Edit
Report

1 Answer

27

I 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:

ExifInterface exif = new ExifInterface("filepath");  
exif.getAttribute(ExifInterface.TAG_ORIENTATION);
answered 2010-02-19T21:35:40.757

Your Answer