try
{
BufferedImage bufImg = new BufferedImage(30,30,BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) bufImg.getGraphics();
g2d.drawString("Test123",10,10);
ByteArrayOutputStream boutstream = new ByteArrayOutputStream();
JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(boutstream);
JPEGEncodeParam params = JPEGCodec.getDefaultJPEGEncodeParam(bufImg);
params.setQuality(100, true);
enc.encode(bufImg, params);
File f = new File("test.jpg");
FileOutputStream fimage = new FileOutputStream(new File("test.jpg"));
boutstream.writeTo(fimage);
fimage.close();
} catch (Exception e) {
System.out.println(e);
}
BufferedImage bufImg = new BufferedImage(30,30,BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) bufImg.getGraphics();
g2d.drawString("Test123",10,10);
ByteArrayOutputStream boutstream = new ByteArrayOutputStream();
JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(boutstream);
JPEGEncodeParam params = JPEGCodec.getDefaultJPEGEncodeParam(bufImg);
params.setQuality(100, true);
enc.encode(bufImg, params);
File f = new File("test.jpg");
FileOutputStream fimage = new FileOutputStream(new File("test.jpg"));
boutstream.writeTo(fimage);
fimage.close();
} catch (Exception e) {
System.out.println(e);
}