调整图像大小而不会丢失质量 - java

Hir*_*dra 0 java

如何使用java代码调整图像大小而不失其质量?我试过下面的代码.

    BufferedImage thumbnail =
              Scalr.resize(inputImage,150, 100);
    String formatName = outputImagePath.substring(outputImagePath
            .lastIndexOf(".") + 1);
    ImageIO.write(thumbnail, formatName, new File(outputImagePath));
Run Code Online (Sandbox Code Playgroud)

dod*_*ron 5

如果不将像素丢弃(当使其变小时)或插入/复制像素(当使其变大时),则无法调整图像的大小.因此,在不牺牲质量的情况下不可能"调整"图像的大小.