我使用以下代码调整图像大小,但问题是它们不保持原始纵横比,有什么方法可以在不影响纵横比的情况下调整图像大小。
BufferedImage img1 = new BufferedImage(800, 600,
BufferedImage.TYPE_INT_RGB);
img1.createGraphics()
.drawImage(
ImageIO.read(
new File("/home/rvkydmpo/webapps/ROOT/images/profilePicture/"
+ fileName)).getScaledInstance(800,
600, Image.SCALE_SMOOTH), 0, 0, null);
ImageIO.write(img1, "jpg", new File("/home/rvkydmpo/webapps/ROOT/images/profilePicture/" +fileName));