PHPackages                             lukaswhite/screenshotter - 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. lukaswhite/screenshotter

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

lukaswhite/screenshotter
========================

A PHP package for taking website screenshots using PhantomJS

91605[3 issues](https://github.com/lukaswhite/screenshotter/issues)PHP

Since Jan 4Pushed 10y ago3 watchersCompare

[ Source](https://github.com/lukaswhite/screenshotter)[ Packagist](https://packagist.org/packages/lukaswhite/screenshotter)[ RSS](/packages/lukaswhite-screenshotter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#Screenshotter

A PHP class for creating screenshots of web pages.

Behind the scenes it uses [PhantomJS](http://phantomjs.org/), which is installed for you when you install this package. (Linux, OSX and Windows).

\##Installation

```
composer require lukaswhite/screenshotter

```

Ensure that the `bin/` directory is executable:

```
chmod -R +x vendor/lukaswhite/screenshotter/src/bin

```

(Note that Composer *should* take care of this for you as a post-install command.)

\##Usage

\###1. Create an instance of the class:

```
$screenshotter = new \Lukaswhite\Screenshotter\Screenshotter(
  $ouputPath,
  $cachePath
);

```

\####Parameters

- `$outputPath` is the directory you want to save the resulting screenshot to (without the filename). It should exist, and be writeable.
- `$cachePath` is a directory used for caching, and is required. Again, it should exist and be writeable.

\####Example:

```
$screenshotter = new \Lukaswhite\Screenshotter\Screenshotter(
  '/var/www/example.com/app/storage/screenshots/',
  '/var/tmp/'
);

```

\###2. To take a screenshot:

```
$screenshot = $screenshotter->capture(
  $url,
  $filename,
  $options = []
);

```

\####Parameters:

- `$url` is the URL of the website / web page you want to take a screenshot of.
- `$filename` is the filename to save the screenshot to.
- `$options` is an optional array of additional options:
    - `$width`; if you don't provide this, it's set to 1024px
    - `$height`; if you don't provide this, it's set to 768px
    - `$clipW`; the width to clip (optional)
    - `$clipH`; the height to clip (optional)

\####Return value:

The path to the screenshot.

\####Note on Clipping

If you don't set a clip width &amp; height, the resulting screenshot will be as tall as the web page, regardless of the `$height` setting. In most cases, you'll probably want to set `$clipW` and `$clipH` to match `$width` and `$height` respectively.

\####Examples

```
$screenshot = $screenshotter->capture(
  'http://www.lukaswhite.com',
  'lukaswhitedotcom.png'
);

```

```
$screenshot = $screenshotter->capture(
  'http://www.lukaswhite.com',
  'lukaswhitedotcom.png',
  [
    'clipW' => 1024,
    'clipH' => 768
  ]
);

```

```
$screenshot = $screenshotter->capture(
  'http://www.lukaswhite.com',
  'lukaswhitedotcom.png',
  [
    'width' => 640,
    'height' => 480,
    'clipW' => 640,
    'clipH' => 480
  ]
);

```

\###Additional Options

\####Wait time

Phantomjs loads a page and then waits a certain length of time before taking the screenshot. This is to allow the page to be fully rendered, for images and fonts to be loaded, and so on.

By default it waits for one second. To set the wait time to something else, call the following method:

```
setWait( $value )

```

The value should be in *milliseconds*, for example:

```
$screenshotter->setWait( 3000 ); // wait for three seconds

```

\####SSL Protocol

Phantomjs sometimes has difficulty connecting to HTTPS sites. Chances are if that's the case, the process will appear to suceed but the screenshot will be blank.

In many cases this is because by default Phantomjs uses SSLv3 to connect, which is often either unsupported or - thanks to the [POODLE attack](https://community.qualys.com/blogs/securitylabs/2014/10/15/ssl-3-is-dead-killed-by-the-poodle-attack) - has been disabled.

To get around this, you can use the `setSSLProtocol()` method to explictly tell Phantomjs which SSL protocol to use; the following values are valid:

- `sslv3`
- `sslv2`
- `tlsv1`
- `any`

In most cases, the simplest approach is simply to set it to `all`, i.e.:

```
$screenshotter->setSSLProtocol( 'any' );

```

\####Ignore SSL Errors

Certain SSL errors can also cause difficulty; notably expired or self-signed certificates. You can tell Phantomjs to ignore SSL errors with the following:

```
$screenshotter->ignoreSSLErrors();
// or
$screenshotter->ignoreSSLErrors( TRUE );

```

To tell it *not* to ignore SSL errors - which is the default behaviour - simply set it to `FALSE`:

```
$screenshotter->ignoreSSLErrors( FALSE );

```

\###Exceptions

If the screenshot process fails, it'll throw an Exception. Most likely this will be an instance of:

```
Symfony\Component\Process\Exception\ProcessTimedOutException

```

This type of exception (a timeout) can happen for a variety of reasons, and not just a timeout; because PhantomJS is an external process, it's not always easy to know what failed, so check your parameters. You can also increase the timeout:

```
$screenshotter->setTimeout(60); // Set timeout to 60 seconds, instead of the defaut 10

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1bd633ffdf0f66a73a288c4edcacfa43d214cd95a53384c6fe5ea4b3554dd9d?d=identicon)[lukaswhite](/maintainers/lukaswhite)

---

Top Contributors

[![lukaswhite](https://avatars.githubusercontent.com/u/999014?v=4)](https://github.com/lukaswhite "lukaswhite (11 commits)")

### Embed Badge

![Health badge](/badges/lukaswhite-screenshotter/health.svg)

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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