webkit2png-php is a PHP wrapper for the webkit2png binary available on Mac OS X. Latest webkit2png version tested with this library is v0.6
. For more details on webkit2png, please refer to the webkit2png project page.
- webkit2png binary
- PHP 5.3 or greater
- Shell access
To get started, require the library in your composer.json
file:
{
"require": {
"kjung/webkit2png-php": "1.0.*@dev"
}
}
Then run composer install
or composer update
.
- Start by loading the autoloader:
require_once 'vendor/autoload.php';
- Instantiate the library with the URL:
$webkit2png = new \kjung\webkit2png('http://google.com');
- You can pass options to it but it is not required:
$webkit2png->setOptions(array(
'dir' => 'screenshots/',
'width' => 1000,
'fullsize' => true
)
);
The library default directory is set to images/
but you can always override it with the dir
option as seen above.
- Now Generate the image:
$webkit2png->getImage();
And thats it!
- Optionally, you can access the actual webkit2png query being sent with this method:
$webkit2png->getQuery();
Option | Example |
---|---|
width | 1280 |
height | 800 |
zoom | 2.0 |
fullsize | true |
thumb | true |
clipped | true |
clipped-width | 1000 |
clipped-height | 800 |
scale | 3.0 |
dir | 'images/' |
filename | 'image' |
md5 | true |
datestamp | true |
delay | 3 |
js | '\'javascript string here\'' |
no-image | true |
no-js | true |
transparent | true |
user-agent | '\'user agent string here\'' |
Keep in mind that for js
and user-agent
, you must either use double quotes or escape single quotes so that the string passed is wrapped by quotes.
- Add validation
- Complete Readme
- Composer