I'm having some problems understanding this line of code:
bufferedImage.getScaledInstance(100, -1, Image.SCALE_SMOOTH);
I use it to resize an image with following numbers. Width: 3264px, height: 2448px, horizontal & vertical resolution: 150dpi, size: 2.72MB.
Then I save the bufferedImage into a File using
ImageIO.write(bufferedImage, "jpg", outputFile);
It resulted in a picture with the following numbers: Same width & height (3264x2448), horizontal & vertical resolution: 96dpi, size: 674KB.
Isn't the picture suppose to be 100px
in width, and whatever height to maintain aspect ratio (according to Javadoc)? And why would the result pic have the same width & height, but different hor&ver resolution, and size? Am I missing something, cause it seems like no matter what value of width & height, the result pic is always the same as described above.
I've also read that I should draw the resized BufferedImage
into a Graphics2D
, and save the Graphics2D
into file. Is that the proper way to do it, rather than saving the BufferedImage
straight into file?
The image I'm using is here