code: public static boolean storeAsFile(Bitmap bitmap, File file, Bitmap.CompressFormat format, int quality) {
          OutputStream out = null;
          try {
              out = new BufferedOutputStream(new FileOutputStream(file));
              return bitmap.compress(format, quality, out);
          } catch (FileNotFoundException e) {
              Log.e(TAG, "no such file for saving bitmap: ", e);
              return false;
          } finally {
             CloseableUtils.close(out);
          }
      }
docs: Store the bitmap as a file.
  @param bitmap to store.
  @param format bitmap format.
  @param quality the quality of the compressed bitmap.
  @return the compressed bitmap file.