with Java:
public void saveScreenToJPGFile(BufferedImage image, String fileUrl) {
try {
// create a blank, RGB, same width and height, and a white background
BufferedImage newBufferedImage = new BufferedImage(image.getWidth(),
image.getHeight(), BufferedImage.TYPE_INT_RGB);
newBufferedImage.createGraphics().drawImage(image, 0, 0, Color.WHITE, null);
ImageOutputStream ios = ImageIO.createImageOutputStream(new File(fileUrl));
Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = iter.next();
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(0.90F);
writer.setOutput(ios);
writer.write(null, new IIOImage(newBufferedImage, null, null), iwp);
writer.dispose();
System.out.println(" screenshot saved: " + fileUrl);
} catch (Exception e) {
e.printStackTrace();
}
}