public static Bitmap rotateImage(Bitmap imageToOrient, int degreesToRotate) {
        Bitmap result = imageToOrient;
        try {
            if (degreesToRotate != 0) {
                Matrix matrix = new Matrix();
                matrix.setRotate(degreesToRotate);
                result = Bitmap.createBitmap(
                        imageToOrient,
                        0,
                        0,
                        imageToOrient.getWidth(),
                        imageToOrient.getHeight(),
                        matrix,
                        true);
            }
        } catch (Exception e) {
            if (Log.isLoggable(TAG, Log.ERROR)) {
                Log.e(TAG, "Exception when trying to orient image", e);
            }
        }
        return result;
    }
This is an expensive operation that copies the image in place with the pixels rotated.
If possible rather use getOrientationMatrix, and set that as the imageMatrix on an ImageView.

@param imageToOrient Image Bitmap to orient.
@param degreesToRotate number of degrees to rotate the image by. If zero the original image is returned
                       unmodified.
@return The oriented bitmap. May be the imageToOrient without modification, or a new Bitmap.
core/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java