- I have a image in gallery which was taken from camera
- I am trying to find out if the image is
portrait
orlandscape
I have the path obtained from below code as
/storage/emulated/0/DCIM/Camera/IMG_20181110_211757.jpg
Then i am using the ExifInterface to find the orientation:
public static void getCameraPhotoOrientation(Activity activity, String imagePath) {
String path =getPath(activity,imagePath);
try {
ExifInterface ei = new ExifInterface(path);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
Timber.d("Type-1");
break;
case ExifInterface.ORIENTATION_ROTATE_180:
Timber.d("Type-2");
break;
case ExifInterface.ORIENTATION_ROTATE_90:
Timber.d("Type-3");
break;
case ExifInterface.ORIENTATION_UNDEFINED:
Timber.d("Type-4");
break;
}
}catch (IOException ex){
ex.printStackTrace();
}
}
I always get orientation as ExifInterface.ORIENTATION_UNDEFINED
How to resolve this