@Grab(group='com.github.sarxos', module='webcam-capture', version='0.3.9') import java.awt.* import java.awt.image.* import javax.imageio.* import com.github.sarxos.webcam.* def webcam = Webcam.getDefault() if( webcam == null )return println "Webcam: " + webcam.getName() webcam.setViewSize(new Dimension(640, 480)) webcam.open() BufferedImage image = webcam.getImage() ImageIO.write(image, "PNG", new File("test.png"))