}
String filename = imgFile.getName().substring(0, imgFile.getName().lastIndexOf("."));
InputStream in = new FileInputStream(imgFile);
OutputStream out = new FileOutputStream(new File(resultDir, "SCALE_" + filename + "-" + name + ".jpg"));
WriteRender wr = null;
try {
ReadRender rr = new ReadRender(in, true);
ImageWrapper wi = rr.render();
PlanarImage img = wi.getAsPlanarImage();
if ("progbicu".equalsIgnoreCase(name)) {
img = doProgressiveBicubic(img);
} else if ("Nearest".equalsIgnoreCase(name)) {
img = doScaleNearest(img);
} else if ("Bilinear".equalsIgnoreCase(name)) {
img = doScaleBilinear(img);
} else if ("Bicubic".equalsIgnoreCase(name)) {
img = doScaleBicubic(img);
} else if ("Bicubic2".equalsIgnoreCase(name)) {
img = doScaleBicubic2(img);
} else if ("SubsampleAverage".equalsIgnoreCase(name)) {
img = doSubsampleAverage(img);
} else if ("lanczos".equalsIgnoreCase(name)){
img = doLanczos(img);
} else {
throw new IllegalArgumentException("Unknown alg " + name);
}
wi.setImage(img);
wr = new WriteRender(wi, out);
wr.render();
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}