The release of Google Chrome 59 brought some really cool features. Â One of them in particular was all over the technology news – headless mode. Â Being able to run the browser engine without the graphical interface, and having control from the command line and API has many benefits.
One of the benefits is being able to take web page screenshots. Â “Easily convert webpages to images using PHP” is one of the many blogs and articles that explain how to do it, using your preferred programming language (or mine in this case). Â Browsershot is a very simple PHP library, which you can install with Composer and start using straight away.
I’ve tried it out and it works pretty well. Â The screenshot above has been taken by the following script:
<?php require_once 'vendor/autoload.php'; use Spatie\Browsershot\Browsershot; Browsershot::url('https://mamchenkov.net') ->windowSize(1600,900) ->save('screenshot.png');