2 Ways to Capture Website Screenshots from the Command-line on Linux

You might be using ksnip or flameshot to take screenshots of single or multiple web pages. No doubt, both are great tools that provide you with rich full features that make it easy to take screenshots and later edit the image.

What if I told you about some hidden command-line tools that let you easily capture website screenshots from your terminal app? You heard it right. In this article, you will learn how to take a website screenshot from your terminal app in Linux.

1. Pageres: Capture Website Screenshots

Pageres is a great tool for taking hundreds of screenshots of multiple websites in less than a minute. All you have to do is pass the URL of the website and specify the variables that will allow you to specify the screenshot resolution, date, and time.

You need to make sure Snap is installed and running as a service on your system and then follow the below command to start the installation process.

$ sudo snap install pageres 

After the installation is complete, you can execute the following command to get a basic idea of how this application works.

$ pageres https://trendoceans.com

Below is the output of the above command.

Taking website screenshots from the Pageres command-line tool
Taking website screenshots from the Pageres command-line tool

Without any parameters, it will capture the website screenshot in its default (1366×768) resolution. However, you can tweak this to a custom value by using the available variables as mentioned below.

  • url: The URL without protocol (https) and web (www), eg. https://trendoceans.io/blog/ becomes yeoman.io!blog
  • size: Specified size, eg. 1440x1080
  • width: Width of the specified size, eg. 1440
  • height: Height of the specified size, eg. 1080
  • crop: Outputs -cropped when the crop option is true
  • date: The current date (YYYY-MM-DD), eg. 2021-08-26
  • time: The current time (HH-mm-ss), eg. 21-15-11

For example, to capture a webpage screenshot in the 1440x1080 resolution, use the following command.

$ pageres https://trendoceans.com 1440x1080

Below is the output of the above command.

Custom resolution while capturing webpage screenshots through the Pageres command-line tool
Custom resolution while capturing webpage screenshots through the Pageres command-line tool

If you want to capture screenshots of multiple websites with multiple resolutions, then specify each one of them, as shown below.

$ pageres https://trendoceans.com https://google.com 1440x1080 1336x768

Below is the output of the above command.

Screenshot of multiple webpages with multiple resolutions
Screenshot of multiple webpages with multiple resolutions

Right now, it is capturing the complete web page, although you can easily take a screenshot of the visible region of the page by using the -cropped flag, as shown below.

$ pageres https://trendoceans.com 1440x1080 -cropped

Below is the output of the above command.

Cropped Screenshot of Webpage
Cropped Screenshot of Webpage

To learn more, you can check the help section of this application by using the following command.

$ pageres -h

2. Cutycapt: Capture WebKit’s Rendering of a Web Page

Cutycapt is an amazing open-source tool to capture webkit’s rendering of a web page into a variety of vector and bitmap formats like SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP.

It is available to install on Ubuntu or other distributions from the default repository, and even Kali Linux ships it as the default tool of its operating system.

Other users can execute the following command to install it on their Linux system.

$ sudo apt install cutycapt

After the installation is complete, you can capture the screenshot of a web page by specifying the URL with the --url option and save it with your choice of filename by providing the filename in the --out option, as shown below.

$ cutycapt --url=https://www.trendoceans.com --out=to.png

Below is the output of the above command.

Taking website screenshots from the cutycapt command-line tool
Taking website screenshots from the cutycapt command-line tool

You can use --min-width and --min-height to specify a custom resolution for the screenshot, as shown below.

$ cutycapt --url=https://www.trendoceans.com --min-width=1440 --min-height=1080 --out=to.png

Below is the output of the above command.

Custom resolution while capturing webpage screenshots through the cutycapt command-line tool
Custom resolution while capturing webpage screenshots through the cutycapt command-line tool

Furthermore, you can even set a delay time, javascript enable/disable, auto load image on/off, user-agent, etc. You can refer to the manual page to learn more about them.

$ man cutycapt

I hope this article turned out to be useful for you. If you have any more questions, then do let us know in the comment section.

Leave a Reply