When I\'am selecting image from gallery and showing the image in ImageView some of the images is auto rotated with 90 degrees.
How do I disable this?
Co
You should rotate this images yourself. Read image orientation value from content provider, specifically Images.Media.ORIENTATION field and rotate it correspondingly.
This images are stored rotated. Rotate angle is saved in media database.
public int getOrientation(Uri selectedImage) {
int orientation = 0;
final String[] projection = new String[]{MediaStore.Images.Media.ORIENTATION};
final Cursor cursor = context.getContentResolver().query(selectedImage, projection, null, null, null);
if(cursor != null) {
final int orientationColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.ORIENTATION);
if(cursor.moveToFirst()) {
orientation = cursor.isNull(orientationColumnIndex) ? 0 : cursor.getInt(orientationColumnIndex);
}
cursor.close();
}
return orientation;
}
You can rotate image using ImageView.setImageMatrix()
for example.