1        Image src = javax.imageio.ImageIO.read(file);
 2        int width = 116// 小图宽
 3        int height = 90// 小图高
 4        BufferedImage tag = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
 5        // 绘制缩小后的图
 6        tag.getGraphics().drawImage(src, 00,width, height, null); 
 7        String spicBasePath = baseSmallPicturePath+ getFileDir(curname);
 8        String smallpicpath = tomcatPath+spicBasePath;
 9        smallpicpath = new FileOperate().createDir(smallpicpath);
10        File smallpicfile = new File(smallpicpath,newfilename);
11        // 输出到文件流
12        FileOutputStream out = new FileOutputStream(smallpicfile); 
13        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
14        encoder.encode(tag); // 近JPEG编码
15        out.close();