iwparam.setCompressionQuality(jpegQuality);//Set here your compression rate
ImageWriter iw = (ImageWriter)ImageIO.getImageWritersByFormatName("jpg").next();
ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
iw.setOutput(ios);
iw.write(null, new IIOImage(scaled, null, null), iwparam);
iw.dispose();
ios.close();
scaled.flush();
scaled = null;
image = com.lowagie.text.Image.getInstance(baos.toByteArray());