image = com.lowagie.text.Image.getInstance(img, bgColor);
}
else{
BufferedImage scaled = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D g3 = scaled.createGraphics();
g3.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);
g3.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);