ExifInterface exif;
try
{
exif = new ExifInterface(filePath);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
Matrix matrix = new Matrix();
int check = 0;
if (orientation == 6)
{
check = 90;
matrix.postRotate(90);
}
else if (orientation == 3)
{
check = 180;
matrix.postRotate(180);
}
else if (orientation == 8)
{
check = 270;
matrix.postRotate(270);
}
scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0,scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true);
}