public File processImage(File img, final URI uri) throws DjatokaException {
final String imgPath = img.getAbsolutePath();
final String fmt = formatMap.get(imgPath.substring(imgPath.lastIndexOf('.') + 1).toLowerCase());
try {
if (fmt == null || !ImageProcessingUtils.isJp2Type(fmt)) {
final ICompress jp2 = new KduCompressExe();
final File jp2Local = File.createTempFile("cache" + uri.hashCode() + "-", ".jp2");
if (!jp2Local.delete() && LOGGER.isWarnEnabled()) {
LOGGER.warn("File not deleted: {}", jp2Local);
}
jp2.compressImage(img.getAbsolutePath(), jp2Local.getAbsolutePath(), new DjatokaEncodeParam());
if (!img.delete() && LOGGER.isWarnEnabled()) {
LOGGER.warn("File not deleted: {}", img);
}
img = jp2Local;
} else {