Both Chrome and Firefox have the ability to take screenshots of web sites directly from the command line. This allows you to create scripts or scheduled tasks that automatically take screenshots of web sites at various intervals.

When using this feature, the browsers will be started in a headless mode, which means the browser will not become visible to the user and will close after performing the desired request. Headless mode makes it ideal when using this feature during scripted tasks as the browser windows will not appear and interrupt other tasks you are working on.

Taking screenshots from the command line using Chrome

Using Chrome, you can take a screenshot of the first screen of visible content of a web page using the following command:

"[path_to_chrome]" --headless --screenshot="[path_to]\image.png" "[url]"

When capturing screenshots using Chrome in Windows, if you leave out the path where you wish to save the image, it will try and save the screenshot to the Chrome folder under C:\ProgramFiles (x86). This will cause it to fail as users do not have permission to create files in that folder.

Instead you should specify the full path to where you wish to save the screenshot as shown in the example below.

"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --screenshot="D:\test\chrome.png" "https://www.bleepingcomputer.com/"

Taking a screenshot with Chrome is illustrated in the image below.

Taking screenshots from the command line in Chrome

When taking screenshots using the above command, it will only make an image of a portion of the requested web page. If you wish to create a screenshot of the entire web page, you can use the --window-size=width,height argument as shown below.

To make sure you capture the full page, it is recommended to utilize a width and height greater than the existing page.

"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --screenshot="d:\test\chrome.png" --window-size=1024,2550 "https://www.bleepingcomputer.com/"

After using the above command, your screenshot will look similar to the image below.

Full Page Chrome Screenshot

When creating screenshots, Chrome will show the scrollbars. To remove the scrollbars you can add the --hide-scrollbars argument to the command like below.

"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --screenshot="d:\test\chrome.png" --hide-scrollbars --window-size=1024,2550 "https://www.bleepingcomputer.com/"

Taking screenshots from the command line in Firefox

Firefox also has the ability to take screenshots from the command line. The advantage to using Firefox for this task is that it defaults to taking full screen images automatically so you do not have to fiddle with the width and the height of the screenshot.

To take a screenshot from the command line in Firefox, you would use the following command:

"[path_to_firefox" --screenshot [url]

For example in Windows, to take a screenshot of BleepingComputer.com from the command line you would use the following command, which saves the file to the directory where the command was executed.

"c:\Program Files\Mozilla Firefox\firefox.exe" --screenshot https://www.bleepingcomputer.com/

How the command works is illustrated in the image below.

Taking a screenshot from the command line

When a screenshot is created it will be named screenshot.png and by default contains a full screen image of the entire requested web page.

Screenshot of BleepingComputer.com

Like Chrome, you can also specify the folder and filename to save the screenshot under by specifying it after the --screenshot command as shown below.

c:\Program Files\Mozilla Firefox\firefox.exe" --screenshot D:\test\firefox.png https://www.bleepingcomputer.com/

You can also specify the width and height of the taken image using the --window-size=width,height argument as shown below.

c:\Program Files\Mozilla Firefox\firefox.exe" --screenshot D:\test\firefox.png https://www.bleepingcomputer.com/ --window-size=800,450

When testing both browsers for this article, I found Firefox to not only be easier to use for full screen screenshots, but I also found it was faster when creating them.