code: public static void compressToFile(@NonNull final Bitmap bitmap, @NonNull final File file,
                                        @NonNull final CompressFormat format, final int quality)
              throws IOException {
          Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null");
          Condition.INSTANCE.ensureNotNull(file, "The file may not be null");
          Condition.INSTANCE.ensureNotNull(format, "The format may not be null");
          Condition.INSTANCE.ensureAtLeast(quality, 0, "The quality must be at least 0");
          Condition.INSTANCE.ensureAtMaximum(quality, 100, "The quality must be at maximum 100");
          OutputStream outputStream = null;
  
          try {
              outputStream = new FileOutputStream(file);
              boolean result = bitmap.compress(format, quality, outputStream);
  
              if (!result) {
                  throw new IOException(
                          "Failed to compress bitmap to file \"" + file + "\" using format " +
                                  format + " and quality " + quality);
              }
          } finally {
              StreamUtil.INSTANCE.close(outputStream);
          }
      }
docs: Compresses a specific bitmap and stores it within a file.
  
  @param bitmap
  The bitmap, which should be compressed, as an instance of the class {@link Bitmap}.
  The bitmap may not be null
  @param file
  The file, the bitmap should be compressed to, as an instance of the class {@link
  File}. The file may not be null
  @param format
  The format, which should be used to compress the bitmap, as a value of the enum
  {@link CompressFormat}. The format must either be <code>JPEG</code>, <code>PNG</code>
  or <code>WEBP</code>
  @param quality
  The quality, which should be used to compress the bitmap, as an {@link Integer}
  value. The quality must be at least 0 (lowest quality) and at maximum 100 (highest
  quality)
  @throws FileNotFoundException
  The exception, which is thrown, if the given file could not be opened for writing
  @throws IOException
  The exception, which is thrown, if an error occurs while compressing the bitmap