Reputation: 1
I have the following class
public void resize(InputStream input, OutputStream output, int width, int height) throws IOException {
BufferedImage src = ImageIO.read(input);
BufferedImage dest = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = dest.createGraphics();
AffineTransform at = AffineTransform.getScaleInstance((double)width / src.getWidth(), (double)height / src.getHeight());
g.drawRenderedImage(src, at);
ImageIO.write(dest, "tif", output);
output.close();
}
but in the final result, I lose dpi at 1. how i can keep the dpi in the image?
Upvotes: 0
Views: 120
Reputation: 18838
Dpi is abbreviate of dot per inch and backs to the quality of an image. So, when you change the resolution of an image, you'll loose dpi (dot per inch) of the image in the original size of that image (because you loose the quality!). Hence, it's not possible!
Upvotes: 1