2017 © Pedro Peláez
 

library portrayal

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

image

minicodemonkey/portrayal

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

  • Sunday, November 27, 2016
  • by MiniCodeMonkey
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9,342 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Portrayal

This simple, self-contained library allows you to capture screenshots using PhantomJS., (*2)

Installation

You can install this package through Composer. Edit your project's composer.json file to require minicodemonkey/portrayal., (*3)

"require": {
    "minicodemonkey/portrayal": "~2.0"
}

You will also need to add post-install and post-update scripts to composer.json as well as a config entry to set up the phantomjs binary dependency:, (*4)

"config": {
    "bin-dir": "bin"
},
"scripts": {
    "post-install-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ],
    "post-update-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ]
}

Now run composer update from the terminal, and you're good to go!, (*5)

For more information, check out jakoch/phantomjs-installer, (*6)

Usage

$capture = new \Portrayal\Capture;
$filename = $capture->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

// $filename = /var/folders/6_/htvcfzcd4cb_w9z6bgpmnx5h0000gn/T/d0582362c2ffbf50ee119e504bb64fdc6bba5abd.png

Adjust timeout

The time in seconds to wait on the phantomjs process before giving up. The default timeout is 30s., (*7)

$capture = new \Portrayal\Capture;
$filename = $capture->setTimeout(10)
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Adjust rendering delay

The time in seconds to wait taking the screenshot after the webpage has loaded. The default value is 0.35s (350ms)., (*8)

$capture = new \Portrayal\Capture;
$filename = $capture->setRenderDelay(200)
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Disable animations

This will inject a couple of scripts to disable CSS3 animations as well as jQuery animations. Useful for making sure that subsequent screenshots will have the same state., (*9)

$capture = new \Portrayal\Capture;
$filename = $capture->disableAnimations()
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Change user agent

This allows you to change the HTTP User-Agent header set by the phantomjs process., (*10)

$capture = new \Portrayal\Capture;
$filename = $capture->setUserAgent('MyScreenShotApp 1.0')
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Change browser viewport dimensions

This will change the browser viewport. Please note that this might not necessarily correspond to the exact dimensions of the screenshot. Please see https://github.com/ariya/phantomjs/issues/10619 for additional details., (*11)

$capture = new \Portrayal\Capture;
$filename = $capture->setViewPort($width = 320, $height = 480)
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

This will allow you to set specific cookies for the session, this is for example useful for retaining the cookie state across multiple requests., (*12)

$capture = new \Portrayal\Capture;
$filename = $capture->setCookiesFile('/tmp/cookies.txt')
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

The Versions

27/11 2016

dev-master

9999999-dev

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

27/11 2016

v2.2.0

2.2.0.0

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

19/08 2016

v2.1.2

2.1.2.0

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

14/08 2016

2.1.0

2.1.0.0

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

06/08 2016

2.0.0

2.0.0.0

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

29/07 2016

1.5.0

1.5.0.0

Simple, self-contained library allows you to capture screenshots using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

28/07 2016

1.4.0

1.4.0.0

Simple, self-contained library allows you to capture screenshots using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

28/07 2016

1.3.0

1.3.0.0

Simple, self-contained library allows you to capture screenshots using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

23/07 2016

1.2.0

1.2.0.0

Simple, self-contained library allows you to capture screenshots using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

30/08 2015

1.1.1

1.1.1.0

Simple, self-contained library allows you to capture screenshots using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen

30/08 2015

1.1.0

1.1.0.0

Simple, self-contained library allows you to capture screenshots using PhantomJS.

  Sources   Download

The Requires

 

The Development Requires

by Mathias Hansen