File file = new File("d:/temp/1.bmp");
Image img = ImageIO.read(file);
BufferedImage tag = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(img.getScaledInstance(img.getWidth(null), img.getHeight(null), Image.SCALE_SMOOTH), 0, 0, null);
FileOutputStream out = new FileOutputStream("d:/temp/bmp2jpg.jpg");
// JPEGImageEncoder可适用于其他图片类型的转换
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag);
out.close();
转载于:https://my.oschina.net/u/2296689/blog/545790