private static int calculateInSampleSizeByReqestedSize(
      int width, int height, int reqWidth, int reqHeight) {
    int inSampleSize = 1;
    if (height > reqHeight || width > reqWidth) {
      while ((height / 2 / inSampleSize) > reqHeight && (width / 2 / inSampleSize) > reqWidth) {
        inSampleSize *= 2;
      }
    }
    return inSampleSize;
  }
Calculate the largest inSampleSize value that is a power of 2 and keeps both height and width
larger than the requested height and width.
core/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java