|  |  | 
 |  |  |         return zip(file, "jpg", xSize, ySize) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static InputStream zipToJpg(BufferedImage buf, int xSize, int ySize) throws Exception{ | 
 |  |  |         return zip(buf, "jpg", xSize, ySize) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static InputStream zipToPng(File file, int xSize, int ySize) throws Exception{ | 
 |  |  |         return zip(file, "png", xSize, ySize) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static InputStream zipToPng(BufferedImage buf, int xSize, int ySize) throws Exception{ | 
 |  |  |         return zip(buf, "png", xSize, ySize) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static void zipToFile(File file, File toFile, int xSize, int ySize) throws Exception{ | 
 |  |  | 
 |  |  |         os = null ; | 
 |  |  |         return in ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private static InputStream zip(BufferedImage buf, String type, int xSize, int ySize) throws Exception{ | 
 |  |  |         BufferedImage bi = Thumbnails.of(buf).size(xSize, ySize).outputQuality(1f).asBufferedImage(); | 
 |  |  |         ByteArrayOutputStream os = new ByteArrayOutputStream(); | 
 |  |  |         ImageIO.write(bi, type, os); | 
 |  |  |         InputStream in = new ByteArrayInputStream(os.toByteArray()); | 
 |  |  |         bi = null ; | 
 |  |  |         os = null ; | 
 |  |  |         return in ; | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     public static void main(String[] args){ | 
 |  |  |        File f = new File("D:/test.jpg") ; |