Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.media.ExifInterface; import java.io.IOException; public class Main { public static Bitmap getNormalImages(final String path) { return turnPic(path, BitmapFactory.decodeFile(path)); } public static Bitmap getNormalImages(final String path, final Bitmap bitmap) { return turnPic(path, bitmap); } private static Bitmap turnPic(final String path, Bitmap bitmap) { ExifInterface exif; final int ninetyDegrees = 90; int rotationAngle = 0; Matrix matrix = new Matrix(); if (path != null) { try { exif = new ExifInterface(path); int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exifOrientation) { case ExifInterface.ORIENTATION_ROTATE_90: rotationAngle = ninetyDegrees; break; case ExifInterface.ORIENTATION_ROTATE_180: rotationAngle = ninetyDegrees * 2; break; case ExifInterface.ORIENTATION_ROTATE_270: rotationAngle = ninetyDegrees * 3; break; case ExifInterface.ORIENTATION_NORMAL: default: break; } } catch (IOException e) { e.printStackTrace(); return bitmap; } if (rotationAngle != 0) { matrix.postRotate(rotationAngle); } bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } return bitmap; } }