code: public static String getImageAsBase64(@Nonnull File file) throws IOException {
          String contentType = getContentType(file);
          BufferedImage bufferedImage = ImageIO.read(file);
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          ImageIO.write(bufferedImage, contentType.split("/")[1], bos);
          byte[] imageBytes = bos.toByteArray();
  
          return Base64.getEncoder().encodeToString(imageBytes);
      }
docs: Gets the content of an image as a Base64 encoded string.
  
  @param   file            a File pointing to an image
  @return  a Base64 encoded version of that image
  @throws IOException      if there is an error reading the file