sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/preview/PreviewActivity.java
private Bitmap rotateImageIfRequired(String selectedImage) throws IOException {
        BitmapFactory.Options bmOptions = new BitmapFactory.Options();
        Bitmap bitmap = BitmapFactory.decodeFile(selectedImage, bmOptions);

        InputStream input = getContentResolver().openInputStream(Uri.fromFile(new File(selectedImage)));
        ExifInterface ei;
        if (Build.VERSION.SDK_INT > 23)
            ei = new ExifInterface(input);
        else
            ei = new ExifInterface(selectedImage);

        int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return rotateImage(bitmap, 90);
            case ExifInterface.ORIENTATION_ROTATE_180:
                return rotateImage(bitmap, 180);
            case ExifInterface.ORIENTATION_ROTATE_270:
                return rotateImage(bitmap, 270);
            default:
                return bitmap;
        }
    }
/**
     * Rotate an image if required.
     *
     * @param selectedImage Image URI
     * @return The resulted Bitmap after manipulation
     */
Rotate an image if required.
@param selectedImage Image URI
@return The resulted Bitmap after manipulation
Rotate an image if required . @param selectedImage Image URI @return The resulted Bitmap after manipulation
private Bitmap rotateImageIfRequired(String selectedImage) throws IOException {
        BitmapFactory.Options bmOptions = new BitmapFactory.Options();
        Bitmap bitmap = BitmapFactory.decodeFile(selectedImage, bmOptions);
        InputStream input = getContentResolver().openInputStream(Uri.fromFile(new File(selectedImage)));
        ExifInterface ei;
        if (Build.VERSION.SDK_INT > 23)
            ei = new ExifInterface(input);
        else
            ei = new ExifInterface(selectedImage);
        int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return rotateImage(bitmap, 90);
            case ExifInterface.ORIENTATION_ROTATE_180:
                return rotateImage(bitmap, 180);
            case ExifInterface.ORIENTATION_ROTATE_270:
                return rotateImage(bitmap, 270);
            default:
                return bitmap;
        }
    }
private Bitmap rotateImageIfRequired ( String selectedImage ) throws IOException { BitmapFactory . Options bmOptions = new BitmapFactory . Options ( ) ; Bitmap bitmap = BitmapFactory . decodeFile ( selectedImage , bmOptions ) ; InputStream input = getContentResolver ( ) . openInputStream ( Uri . fromFile ( new File ( selectedImage ) ) ) ; ExifInterface ei ; if ( Build . VERSION . SDK_INT > 23 ) ei = new ExifInterface ( input ) ; else ei = new ExifInterface ( selectedImage ) ; int orientation = ei . getAttributeInt ( ExifInterface . TAG_ORIENTATION , ExifInterface . ORIENTATION_NORMAL ) ; switch ( orientation ) { case ExifInterface . ORIENTATION_ROTATE_90 : return rotateImage ( bitmap , 90 ) ; case ExifInterface . ORIENTATION_ROTATE_180 : return rotateImage ( bitmap , 180 ) ; case ExifInterface . ORIENTATION_ROTATE_270 : return rotateImage ( bitmap , 270 ) ; default : return bitmap ; } }
Rotate an image if required.
Rotate an image if required .