code: public static Bitmap shrink(Bitmap bitmap, float scale) {
          if (scale >= 1.0f) {
              return bitmap.copy(bitmap.getConfig(), false);
          }
  
          Matrix matrix = new Matrix();
          matrix.postScale(scale, scale);
  
          return Bitmap.createBitmap(bitmap, 0, 0, (int) (scale * bitmap.getWidth()), (int) (scale * bitmap.getHeight()), matrix, true);
      }
docs: Shrink the bitmap to the specified scale.
  @param bitmap to shrink.
  @param scale the shrink scale, must be < 1.0.
  @return the shrunk bitmap.