public int getExifOrientation(Stringfilepath) {
int degree = 0;
ExifInterface exif =null;
try {
exif = new ExifInterface(filepath);
} catch (IOExceptionex) {
// MmsLog.e(ISMS_TAG, "getExifOrientation():",ex);
}
if (exif !=null) {
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
if (orientation != -1) {
// We only recognize a subset of orientation tag values.
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
default:
break;
}
}
}
returndegree;
}
Bitmap result=BitmapFactory.decodeFile(imageUrl);
if(degree == 90 ||degree == 180 || degree == 270){
//Roate preview icon according to exif orientation
Matrix matrix = new Matrix();
matrix.postRotate(degree);
result = Bitmap.createBitmap(result,
0, 0, result.getWidth(), result.getHeight(), matrix, true);
}