PHPackages                             bnbwebexpertise/pdf-to-image - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. bnbwebexpertise/pdf-to-image

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

bnbwebexpertise/pdf-to-image
============================

Convert a pdf to an image with Imagick extension. Forked from spatie/pdf-to-image

1.2.6(6y ago)0446.4k—8%11MITPHPPHP &gt;=5.5.0

Since Jul 2Pushed 6y ago4 watchersCompare

[ Source](https://github.com/bnbwebexpertise/pdf-to-image)[ Packagist](https://packagist.org/packages/bnbwebexpertise/pdf-to-image)[ Docs](https://github.com/bnbwebexpertise/pdf-to-image)[ RSS](/packages/bnbwebexpertise-pdf-to-image/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (13)Used By (1)

Convert a pdf to an image
=========================

[](#convert-a-pdf-to-an-image)

This package provides an easy to work with class to convert pdf's to images.

Requirements
------------

[](#requirements)

You should have [Imagick](http://php.net/manual/en/imagick.setresolution.php) and [Ghostscript](http://www.ghostscript.com/) installed.

Install
-------

[](#install)

The package can be installed via composer:

```
$ composer require bnbwebexpertise/pdf-to-image
```

Usage
-----

[](#usage)

Converting a pdf to an image is easy.

```
$pdf = new Bnb\PdfToImage\Pdf($pathToPdf);
$pdf->saveImage($pathToWhereImageShouldBeStored);
```

If the path you pass to `saveImage` has the extensions `jpg`, `jpeg`, or `png` the image will be saved in that format. Otherwise the output will be a jpg.

Other methods
-------------

[](#other-methods)

You can get the total number of pages in the pdf:

```
$pdf->getNumberOfPages(); //returns an int
```

By default the first page of the pdf will be rendered. If you want to render another page you can do so:

```
$pdf->setPage(2)
    ->saveImage($pathToWhereImageShouldBeStored); //saves the second page
```

You can override the output format:

```
$pdf->setOutputFormat('png')
    ->saveImage($pathToWhereImageShouldBeStored); //the output wil be a png, no matter what
```

You can configure custom settings (where page is the page number) :

```
$beforeImageReadSettings = function (\Imagick $imagick, $page) {
    $imagick->setColorspace(\Imagick::COLORSPACE_SRGB);

    return $imagick;
};

$beforeImageWriteSettings = function (\Imagick $imagick, $page) {
    $imagick->resizeImage(1024, 1024, \Imagick::FILTER_LANCZOS, 0, true);
    $imagick->setImageColorspace(\Imagick::COLORSPACE_GRAY);

    return $imagick;
};

$pdf = new Pdf($this->testFile, $beforeImageReadSettings, $beforeImageWriteSettings)
    ->saveImage($pathToWhereImageShouldBeStored); //the output will be resized to a grayscale image with a best-fit dimension of 1024x1024
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [B&amp;B Web Expertise](https://github.com/bnbwebexpertise)
- [Freek Van der Herten](https://github.com/spatie)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~131 days

Recently: every ~227 days

Total

12

Last Release

2532d ago

Major Versions

0.0.1 → 1.0.02015-07-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/08424532974ca17db79322a73bfc2a59ad82f01c98e4c9d004674afdcccce5a8?d=identicon)[gabsource](/maintainers/gabsource)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (36 commits)")[![gabsource](https://avatars.githubusercontent.com/u/1851314?v=4)](https://github.com/gabsource "gabsource (5 commits)")[![BenjaminRehn](https://avatars.githubusercontent.com/u/2428038?v=4)](https://github.com/BenjaminRehn "BenjaminRehn (1 commits)")[![jamesdb](https://avatars.githubusercontent.com/u/6299056?v=4)](https://github.com/jamesdb "jamesdb (1 commits)")[![Philhil](https://avatars.githubusercontent.com/u/1251902?v=4)](https://github.com/Philhil "Philhil (1 commits)")[![zaherg](https://avatars.githubusercontent.com/u/27624?v=4)](https://github.com/zaherg "zaherg (1 commits)")

---

Tags

pdfconvertimagepdf-to-imagebnbwebexpertise

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bnbwebexpertise-pdf-to-image/health.svg)

```
[![Health](https://phpackages.com/badges/bnbwebexpertise-pdf-to-image/health.svg)](https://phpackages.com/packages/bnbwebexpertise-pdf-to-image)
```

###  Alternatives

[spatie/pdf-to-image

Convert a pdf to an image

1.4k15.2M64](/packages/spatie-pdf-to-image)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[karkowg/php-mupdf

Minimal PDF to image converter using MuPDF

202.8k](/packages/karkowg-php-mupdf)

PHPackages © 2026

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