java jpg图片按质量保存

2021-01-18 01:16

阅读:432

标签:ons   ESS   java   image   geo   col   set   质量   mode   

        File distImage = new File(distPath);
        ImageWriter jpgWriter = ImageIO.getImageWritersByFormatName("jpg").next();
        ImageWriteParam jpgWriteParam = jpgWriter.getDefaultWriteParam();
        jpgWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        jpgWriteParam.setCompressionQuality(Constant.config.getCompressionQuality());
        jpgWriter.setOutput(ImageIO.createImageOutputStream(distImage));
        IIOImage outputImage = new IIOImage(newImage, null, null);
        jpgWriter.write(null, outputImage, jpgWriteParam);
        jpgWriter.dispose();            

 

java jpg图片按质量保存

标签:ons   ESS   java   image   geo   col   set   质量   mode   

原文地址:https://www.cnblogs.com/rubekid/p/12915388.html


评论


亲,登录后才可以留言!