how to create a screen dump with php on linux

 diversen (25-May-2011 22:40:06)

In order for this to work you will need wkhtmltopdf and the imagemagick tool convert.

On ubuntu you will just do:

sudo aptitude install imagemagick wkhtmltopdf

// save this snippet as url_to_png.php
// usage: php url_to_png.php
if (!isset($argv[1])){
    die("specify site: e.g.\n");

$md5 = md5($argv[1]);
$command = "wkhtmltopdf $argv[1] $md5.pdf";
exec($command, $output, $ret);
if ($ret) {
    echo "error fetching screen dump\n";

$command = "convert $md5.pdf -append $md5.png";
exec($command, $output, $ret);
if ($ret){
    echo "Error converting\n";

echo "Conversion compleated: $argv[1] converted to $md5.png\n"; 

This page has been viewed 14821 times. First hit: 26-Mar-2013 00:31:53
Share email, Google+, Twitter, Facebook.


Add new comment