docs: public static Bitmap scale(ContentResolver contentResolver, Uri uri, int maxWidth, int maxHeight) {
          String tag = "SCALE";
          LogUtils.v(tag, "uri=" + uri.toString());
          try {
              BitmapFactory.Options options = new BitmapFactory.Options();
              options.inJustDecodeBounds = true;
              InputStream input = contentResolver.openInputStream(uri);
              BitmapFactory.decodeStream(input, null, options);
  
              int sourceWidth = options.outWidth;
              int sourceHeight = options.outHeight;
  
              LogUtils.v(tag, "sourceWidth=" + sourceWidth + ", sourceHeight=" + sourceHeight);
              LogUtils.v(tag, "maxWidth=" + maxWidth + ", maxHeight=" + maxHeight);
  
              input.close();
  
              float rate = Math.max(sourceWidth / (float) maxWidth, sourceHeight / (float) maxHeight);
              options.inJustDecodeBounds = false;
              options.inSampleSize = (int) rate;
              LogUtils.v(tag, "rate=" + rate + ", inSampleSize=" + options.inSampleSize);
  
              input = contentResolver.openInputStream(uri);
              Bitmap bitmap = BitmapFactory.decodeStream(input, null, options);
  
              int w0 = bitmap.getWidth();
              int h0 = bitmap.getHeight();
  
              LogUtils.v(tag, "w0=" + w0 + ", h0=" + h0);
  
  
              float scaleWidth = maxWidth / (float) w0;
              float scaleHeight = maxHeight / (float) h0;
              float maxScale = Math.min(scaleWidth, scaleHeight);
              LogUtils.v(tag, "scaleWidth=" + scaleWidth + ", scaleHeight=" + scaleHeight);
  
              Matrix matrix = new Matrix();
              matrix.reset();
              if (maxScale < 1)
                  matrix.postScale(maxScale, maxScale);
  
              Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, w0, h0, matrix, true);
  
  
              input.close();
              // bitmap.recycle();
  
              return resizedBitmap;
  
          } catch (FileNotFoundException e) {
              e.printStackTrace();
              return null;
          } catch (IOException e) {
              e.printStackTrace();
              return null;
          }
  
      }