public BufferedImage change( BufferedImage image ) { try { // Find a jpeg writer ImageWriter writer = null; Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); if (iter.hasNext()) { writer = (ImageWriter) iter.next(); } // Prepare output file /* * Have to hook the output to a BufferedImage somehow here. * writer.setOutput(imageOutputStream); // Set the compression quality ImageWriteParam iwparam = new JPEGImageWriteParam( new Locale("se") ); iwparam.setCompressionMode( ImageWriteParam.MODE_EXPLICIT ); iwparam.setCompressionQuality( (float) (0.75) ); // Write the image writer.write(null, new IIOImage(image, null, null), iwparam); } catch( IOException ioe ) { ioe.printStackTrace(); } return hello; }