Looking for a method to take screen shots of websites I found the program wkhtmltopdf and the associated wkhtmltoimage.
Wkhtmlpdf can take a website page and save it as a pdf file.
I was interested to try out wkhtmltopdf and wkhtmltoimage.
These programs view a given web page and save it as a pdf and image respectively.
Or I could enter parameters to define the size of the image then possibly I could use wkhtmltopdf to create consistent images of web sites for use in a portfolio.
wkhtmltopdf has an image variant called wkhtmltoimage which is used to create images as opposed to pdfs. I used wkhtmltoimate in my experiments.
I began by installing the program. From a terminal I entered:
apt-get install wkhtmltopdf
Using the program can be as simple as specifying the URL of the website and the name of the saved image. For example to capture a snapshot of the VNTweb home page.
wkhtmltoimage https://www.vntweb.co.uk vntweb.png
Further parameters are available, including the width and height of the “browser” view, image quality and cropping.
A summary of these options is shown below:
neil@re123:~$ wkhtmltoimage --help Name: wkhtmltoimage 0.12.1 Synopsis: wkhtmltoimage [OPTIONS]... <input file> <output file> Description: Converts an HTML page into an image, General Options: --crop-h <int> Set height for cropping --crop-w <int> Set width for cropping --crop-x <int> Set x coordinate for cropping --crop-y <int> Set y coordinate for cropping -H, --extended-help Display more extensive help, detailing less common command switches -f, --format <format> Output file format --height <int> Set screen height (default is calculated from page content) (default 0) -h, --help Display help --license Output license information and exit --quality <int> Output image quality (between 0 and 100) (default 94) -q, --quiet Be less verbose -V, --version Output version information and exit --width <int> Set screen width, note that this is used only as a guide line. Use --disable-smart-width to make it strict. (default 1024) Contact: If you experience bugs or want to request new features please visit <https://github.com/wkhtmltopdf/wkhtmltopdf/issues>
I found that when adding width and height parameters these needed to be before the website URL and image filename.
wkhtmltoimage –width 1200 –height 1000 https://www.vntweb.co.uk vntweb.png
Whilst this worked well creating an image of the web page, the resultant rendering was as per a phone or tablet. Also time delayed features such as a cookie warning pop-up were still presented.
The home page for the project is to be found at http://wkhtmltopdf.org/