图像类型转换

 /**
      * 图像类型转换 GIF->JPG GIF->PNG PNG->JPG PNG->GIF(X) 
      */  
     public static void convert(String source, String result)  
     {  
         try  
         {  
             File f = new File(source);  
             f.canRead();  
             f.canWrite();  
            BufferedImage src = ImageIO.read(f);  
             ImageIO.write(src, "JPG", new File(result));  
         }  
         catch (Exception e)  
         {  
             // TODO Auto-generated catch block  
             e.printStackTrace();  
         }  
     }  
   
     /** *//** 
      * 彩色转为黑白 
      * @param source 
      * @param result 
      */  
     public static void gray(String source, String result)  
     {  
         try  
         {  
             BufferedImage src = ImageIO.read(new File(source));  
            ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);  
            ColorConvertOp op = new ColorConvertOp(cs, null);  
             src = op.filter(src, null);  
             ImageIO.write(src, "JPEG", new File(result));  
        }  
         catch (IOException e)  
         {  
             e.printStackTrace();  
         }  
     }  
;