We have a photo gallery that is using servlets to resize images - we need good performance and decent quality, but we just can't get it right. Also, sadly enough, we have only java 1.4, which leaves us to almost no external image libraries (nearly everything i found is java 1.5+) and java image handling is really not good.
If I use this:
private static BufferedImage scaleImage(BufferedImage orig, int type, int w, int h) {
BufferedImage tmp = new BufferedImage(w, h, type);
Graphics2D g2 = tmp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(orig, 0, 0, w, h, null);
g2.dispose();
return tmp;
}
the results are almost same every time (and bad looking) or extremely slow, it depends on the selected hint. I read almost every article about image resizing in java (including this one and it does not help.
Do you have any ideas? Any external libraries for java 1.4 that are fast and have decent quality? Any algorithm that would get good results?