PHPackages                             minicodemonkey/portrayal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. minicodemonkey/portrayal

ActiveLibrary[Image &amp; Media](/categories/media)

minicodemonkey/portrayal
========================

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

v2.2.0(9y ago)09.3kPHPPHP &gt;=5.4.0

Since Aug 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/MiniCodeMonkey/Portrayal)[ Packagist](https://packagist.org/packages/minicodemonkey/portrayal)[ RSS](/packages/minicodemonkey-portrayal/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (11)Used By (0)

[![Build Status](https://camo.githubusercontent.com/5be053f331c77c2d292dc9da2c41f25aebe72388574b27e35ff04de52bfc013d/68747470733a2f2f7472617669732d63692e6f72672f4d696e69436f64654d6f6e6b65792f506f7274726179616c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/minicodemonkey/Portrayal)

Portrayal
=========

[](#portrayal)

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

Installation
------------

[](#installation)

You can install this package through Composer. Edit your project's `composer.json` file to require `minicodemonkey/portrayal`.

```
"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:

```
"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!

> For more information, check out [jakoch/phantomjs-installer](https://github.com/jakoch/phantomjs-installer)

Usage
-----

[](#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

[](#adjust-timeout)

The time in seconds to wait on the phantomjs process before giving up. The default timeout is `30s`.

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

### Adjust rendering delay

[](#adjust-rendering-delay)

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

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

### Disable animations

[](#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.

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

### Change user agent

[](#change-user-agent)

This allows you to change the HTTP User-Agent header set by the phantomjs process.

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

### Change browser viewport dimensions

[](#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.

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

### Specify a custom cookie jar

[](#specify-a-custom-cookie-jar)

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

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

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~30 days

Total

10

Last Release

3495d ago

Major Versions

1.5.0 → 2.0.02016-08-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/220535?v=4)[Mathias Hansen](/maintainers/MiniCodeMonkey)[@MiniCodeMonkey](https://github.com/MiniCodeMonkey)

---

Top Contributors

[![MiniCodeMonkey](https://avatars.githubusercontent.com/u/220535?v=4)](https://github.com/MiniCodeMonkey "MiniCodeMonkey (34 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/minicodemonkey-portrayal/health.svg)

```
[![Health](https://phpackages.com/badges/minicodemonkey-portrayal/health.svg)](https://phpackages.com/packages/minicodemonkey-portrayal)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[spatie/image

Manipulate images with an expressive API

1.4k58.5M175](/packages/spatie-image)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[alchemy/phpexiftool

Exiftool driver for PHP

40190.6k4](/packages/alchemy-phpexiftool)[illuminate/process

The Illuminate Process package.

44813.9k96](/packages/illuminate-process)[jolicode/media-bundle

A media management bundle for Symfony applications, with Easyadmin and SonataAdmin integrations.

11210.3k](/packages/jolicode-media-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
