Reputation: 453
I understand that screen.capture() should be used in order to take screenshot using Sikuli. How can i save the image to a file?
Upvotes: 1
Views: 3736
Reputation: 46
Cannot comment because of reputation. Additionally, you can capture a specific region:
Region myRegion = new Region(0, 0, 250, 500);
ImageIO.write(screen.capture(myRegion).getImage(), "jpg", new File("screen.jpg"));
The region object would be defined according to your needs. In this case I created a simple region at x=0, y=0, width=250, height=500.
Upvotes: 0
Reputation: 1723
From the resulting org.sikuli.script.ScreenImage
you can getImage
that returns a java.awt.image.BufferedImage
. To save that to a file you can use javax.imageio.ImageIO
:
ImageIO.write(screen.capture().getImage(), "jpg", new File("screen.jpg"));
Upvotes: 2