Sunday, November 18, 2018

Taking screenshots by headless Chrome from command line

To capture a screenshot of a page, use the --screenshot flag:

google-chrome --headless  --screenshot https://i88.ca/

# Size of a standard letterhead.
chrome --headless  --screenshot --window-size=1280,1696 https://i88.ca/

# Nexus 5x
chrome --headless  --screenshot --window-size=412,732 https://i88.ca/

Running with --screenshot will produce a file named screenshot.png in the current working directory.