ich möchte in einem Servlet ein Bild verkleinenern, wie macht ihr das?
is das so ok?
hier hängt er 2-3 Sekunden! is das normal? alles andere geht relativ schnell
Code:
public BufferedImage resizeImage(BufferedImage image, int width){
int factor = image.getWidth()/width;
int height = image.getHeight()/factor;
image.flush();
Image thumb = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
return getBufferedImage(thumb);
}
public BufferedImage getBufferedImage(Image image) {
int w = image.getWidth(null);
int h = image.getHeight(null);
BufferedImage result = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = result.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
return result;
}
is das so ok?
Code:
int w = image.getWidth(null);