java压缩图片速度慢 怎么优化?

我使用的是如下方法,但是在运行的时候速度太慢,还有压缩多个文件时,其中的某个会有不压缩的情况,需要在哪里进行优化,或者有那些其他的技术?需要压缩不同类型的图片

 File qianfile = new File(strArray[i]);  
                double imgsize=(double) (qianfile.length()/1024);
                System.out.println("压缩前size:" + imgsize+"KB");
                src = javax.imageio.ImageIO.read(new File(strArray[i])); //构造Image对象 
                String img_midname=strArray[i].substring(0,strArray[i].indexOf("."))+strArray[i].substring(path.indexOf(".")); 
                int old_w=src.getWidth(null); //得到源图宽 
                int old_h=src.getHeight(null); 
                BufferedImage tag = new BufferedImage(old_w,old_h,BufferedImage.TYPE_INT_RGB);   
                tag.getGraphics().drawImage(src.getScaledInstance(old_w, old_h,  Image.SCALE_SMOOTH), 0,0,null); 
                FileOutputStream newimage=new FileOutputStream(img_midname); //输出到文件流 
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage); 
                JPEGEncodeParam jep=JPEGCodec.getDefaultJPEGEncodeParam(tag); 
                /* 压缩质量 */ 
                jep.setQuality(0.3f, true); 
                encoder.encode(tag, jep); 
                newimage.close(); 

http://blog.csdn.net/u011310399/article/details/44096357