public static void main(String[] args) throws IOException {
File input = new File("C://000.jpg");
Image src = javax.imageio.ImageIO.read(input);
int width = (int) (src.getWidth(null) * 70 / 100.0);
int height = (int) (src.getHeight(null) * 70 / 100.0);
BufferedImage bufferedImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
bufferedImage.getGraphics().drawImage(src.getScaledInstance(width, height, Image.SCALE_SMOOTH),0, 0, null);
FileOutputStream imgOutputStream = new FileOutputStream("C://001.jpg");
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(imgOutputStream);
encoder.encode(bufferedImage);
}
以上是 生成 70%的缩略图。。。
还没有评论,来说两句吧...