사진을 찍고 회전값을 구할 수 있습니다.
public static int getImageOrientation(String path){
int rotation =0;
try {
ExifInterface exif = new ExifInterface(path);
int rot= exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
if(rot == ExifInterface.ORIENTATION_ROTATE_90){
rotation = 90;
}else if(rot == ExifInterface.ORIENTATION_ROTATE_180){
rotation = 180;
}else if(rot == ExifInterface.ORIENTATION_ROTATE_270){
rotation = 270;
}else{
rotation = 0;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rotation;
}
회전값 구한 이후 Matrix 이용하셔서 이미지 회전 시키시면 됩니다.
public static Bitmap imgRotate(Bitmap bmp, int orientation){
int width = bmp.getWidth();
int height = bmp.getHeight();
Matrix matrix = new Matrix();
matrix.postRotate(orientation);
Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, width, height, matrix, true);
bmp.recycle();
return resizedBitmap;
}