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 ; }
Get image filename to be used for the URL with file extension matching the image format which is produced by this servlet .