I'm trying to shoot picture and store it into internal storage by using the following code:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
takenPhoto = new File(uploadsFolder, getNewPicFileName());
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(takenPhoto));
startActivityForResult(intent, SHOOT_MEDIA_REQUEST_CODE);
The problem is that on Nexus S and Galaxy S devices default and the single orientation for ACTION_IMAGE_CAPTURE intent is landscape. If i shoot picture in portrait mode, that picture is stored into "takenPhoto" file rotated.
That problem seems appearing only on Samsung Galaxy S devices (Galaxy S and Nexus S), another devices i tried make auto-rotate depending on orientation during image shooting.
I will very appreciate any help on that issue.
From what I can tell, this is happening because the MediaStore.Images.ImageColumns.ORIENTATION
value isn't being set by this Intent. It does get set when things come through the normal camera app.
On my Nexus S, however, the file still gets the correct EXIF data. So you could get the orientation like this:
ExifInterface exif = new ExifInterface("filepath");
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
Then you could use use ContentResolver.update add the correct ORIENTATION data. You just need to translate the ExifInterface orientation options to degrees rotated.
Your other option is to create your own Activity to operate the camera hardware and record the file. You'd then keep track of rotations & write the value into the metadata when saving a captured image. Since the Camera app is part of Android, you could probably copy & modify it without too much pain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With