How to resolve display image orientation issue in android device ?
For this issue I use sdcard image url and check the orientation of that image if orientation if not proper then set proper orientation and generate that correct orientation bitmap and Set to the ImageView.
I use Below Code for performing this action
Below is java code :
String picurl ; int rotate = 0; try { this.getContentResolver().notifyChange(Uri.fromFile(new File(picurl)), null); ExifInterface einterface = new ExifInterface(picurl.getAbsolutePath()); int orientation = eiterface.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) { }
For this above code I get the image orientation and as per orienation I rotate the image :
Matrix matrix = new Matrix(); matrix.postRotate(rotate); b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, true);