I have now implemented `ExifInterface, but it doesn't seem to rotate any of the images taken by the camera intent. The images are still returning in landscape instead of portrait.
Here is my code:
Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "My Fodler");
imagesFolder.mkdirs();
File image = new File(imagesFolder, "My_" + timeStamp + ".jpg");
fileUri = Uri.fromFile(image);
ExifInterface exif = null;
try {
exif = new ExifInterface(image.getAbsolutePath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(imageIntent, TAKE_PICTURE);
}
What am I doing wrong here? Please help?