大多数手机的相机景观,这意味着如果您以纵向拍摄照片,所得照片将旋转90度。在这种情况下,相机软件应该以照片应该被浏览的方向填充EXIF数据。 I copy this answer from here
其他方式,你可以从相机获得旋转,然后做任何你想要返回的图像。 Full code here这个关于图像选择器的示例,但返回的代码处理图像帮助我控制图像的旋转。
private int getRotationFromCamera(Context context, Uri imageFile) {
int rotate = 0;
try {
context.getContentResolver().notifyChange(imageFile, null);
ExifInterface exif = new ExifInterface(imageFile.getPath());
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;
}
} catch (Exception e) {
e.printStackTrace();
}
return rotate;
}