/**
* @author yukaida
* @param absolutePath 照片的絕對路勁
* @return 重新調整方向之後的bitmap圖片
*/
public static Bitmap orientation(String absolutePath){
Bitmap bitmap_or=BitmapFactory.decodeFile(absolutePath);
try {
ExifInterface exif = new ExifInterface(absolutePath);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Log.d("EXIF", "Exif: " + orientation);
Matrix matrix = new Matrix();
if (orientation == 6) {
matrix.postRotate(90);
}
else if (orientation == 3) {
matrix.postRotate(180);
}
else if (orientation == 8) {
matrix.postRotate(270);
}
bitmap_or= Bitmap.createBitmap(bitmap_or, 0, 0, bitmap_or.getWidth(), bitmap_or.getHeight(), matrix, true); // rotating bitmap
return bitmap_or;
}
catch (Exception e) {
}
return null;
}