when uploading this image to the server. it is rotated with 90 degree. here is a link for the image :
https://drive.google.com/file/d/0Bw8vnOWKrLfgWElsRW81SmxXeDA/view?usp=sharing
here is the code to check orientation. but it doesn't detect roation:
/**
* get image matrix rotation by uri
*/
private static Matrix matrixUriImgRotation(Uri uri) {
Log.i("imageRotatin", "image rotation called");
ExifInterface exif = null;
try {
exif = new ExifInterface(uri.getPath());
} catch (Exception e) {
Log.i("imageRotatin", "exception:" + e.getMessage());
}
//get image rotation
int exifRotation = 0;
if (exif != null) {
exifRotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
Log.i("imageRotatin", "exif not null");
}
//convert exif rotation to degrees
int rotationInDegrees = 0;
if (exifRotation == ExifInterface.ORIENTATION_ROTATE_90) {
rotationInDegrees = 90;
} else if (exifRotation == ExifInterface.ORIENTATION_ROTATE_180) {
rotationInDegrees = 180;
} else if (exifRotation == ExifInterface.ORIENTATION_ROTATE_270) {
rotationInDegrees = 270;
}
//build matrix
Matrix matrix = new Matrix();
if (exifRotation != 0) {
Log.i("imageRotatin", "rotationInDegree:" + rotationInDegrees);
matrix.preRotate(rotationInDegrees);
}
return matrix;
}
note: other images is uploaded without problem.