码迷,mamicode.com
首页 > 编程语言 > 详细

java jpg图片按质量保存

时间:2020-05-19 10:47:32      阅读:87      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!