The BufferedImage object is mainly used to save the original image in jpg format:
public static void thumbImage(String input,String newFile) throws Exception {
Image src = javax.imageio.ImageIO.read(new File(input));
int width = src.getWidth(null);// 获取图源宽度
int height = src.getHeight(null);// 获取图源高度
BufferedImage thumb = new BufferedImage(width / 1, height / 1,
BufferedImage.TYPE_INT_RGB);
// 绘制缩小后的图
thumb.getGraphics().drawImage(src, 0, 0, width / 1, height / 1, null);
File file = new File(newFile);// 输出到文件流
ImageIO.write(thumb, "jpg", file);
}
What is the effect of use: the original image is -1947K, and the converted image is -716K. The effect seems to be more obvious, and the difference in image quality is not too big.