Here you can find the source of setCompressionQuality(ImageWriteParam params, int quality)
private static void setCompressionQuality(ImageWriteParam params, int quality)
//package com.java2s; //License from project: Open Source License import javax.imageio.ImageWriteParam; public class Main { private static void setCompressionQuality(ImageWriteParam params, int quality) { if (quality <= 0) { quality = 1;/* w w w. ja v a 2 s . com*/ } if (quality > 100) { quality = 100; } try { params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); params.setCompressionQuality((float) quality / 100f); } catch (Exception e) { // DO nothing since compression not supported } } }