Java tutorial
//package com.java2s; import java.io.IOException; import android.graphics.Bitmap; import android.graphics.Matrix; import android.media.ExifInterface; public class Main { /** * This method resets bitmap orientation to 0 if not. * * @param path * @param bitmap * @return bitmap with 0 degree orientation */ public static Bitmap resetBitmapOrientation(String path, Bitmap bitmap) { // TODO Auto-generated method stub int rotate = 0; try { ExifInterface ei = new ExifInterface(path); int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; default: // do nothing... break; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (rotate == 0) { return bitmap; } else { Matrix m = new Matrix(); m.postRotate(rotate); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true); } } }