code: public static String getImageFileName(String originalFilename) {
      String namePart = StringUtils.substringBeforeLast(originalFilename, ".");
      String extensionPart = StringUtils.substringAfterLast(originalFilename, ".");
  
      // use PNG format if original image is PNG, otherwise always use JPEG
      if (StringUtils.equalsIgnoreCase(extensionPart, FileExtension.PNG)) {
        extensionPart = FileExtension.PNG;
      }
      else {
        extensionPart = FileExtension.JPEG;
      }
      return namePart + "." + extensionPart;
    }
docs: Get image filename to be used for the URL with file extension matching the image format which is produced by this
  servlet.
  @param originalFilename Original filename of the image to render.
  @return Filename to be used for URL.