PHPackages                             steffen-99/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. steffen-99/pdf-to-image

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

steffen-99/pdf-to-image
=======================

Convert a pdf to an image

2.1(4y ago)06.0k↓30%MITPHPPHP ^7.4|^8.0

Since Jul 2Pushed 4y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (31)Used By (0)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/605ae9b5a5f967053599ea68c31dd51e702ba18481490ee760a2429fdc07aafb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f7064662d746f2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/pdf-to-image)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/b3e084004aa5d1e80a32c13e81cd03a2e6aaeea8dfb44943edf19c0854fed29d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f7064662d746f2d696d6167652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/pdf-to-image)[![Quality Score](https://camo.githubusercontent.com/3d8bf7a5915bc81f2bd8a1d5578106208216f0ccc6c89e6d1c627385ced1143c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f7064662d746f2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/pdf-to-image)[![StyleCI](https://camo.githubusercontent.com/de2459259700666ebb9970f2c3e4c02888ff3bb4a121a7cd955f3c0001969fb8/68747470733a2f2f7374796c6563692e696f2f7265706f732f33383431393630342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/38419604)[![Total Downloads](https://camo.githubusercontent.com/d6855f78defae657a3d40fb74cf546d576726907dbc0a17048f6877fa9874e13/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f7064662d746f2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/pdf-to-image)

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

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

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

[](#requirements)

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

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

[](#installation)

The package can be installed via composer:

```
$ composer require steffen-99/pdf-to-image
```

Usage
-----

[](#usage)

Converting a pdf to an image is easy.

```
$pdf = new Spatie\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 set the quality of compression from 0 to 100:

```
$pdf->setCompressionQuality(100); // sets the compression quality to maximum
```

Issues regarding Ghostscript
----------------------------

[](#issues-regarding-ghostscript)

This package uses Ghostscript through Imagick. For this to work Ghostscripts `gs` command should be accessible from the PHP process. For the PHP CLI process (e.g. Laravel's asynchronous jobs, commands, etc...) this is usually already the case.

However for PHP on FPM (e.g. when running this package "in the browser") you might run into the following problem:

```
Uncaught ImagickException: FailedToExecuteCommand 'gs'

```

This can be fixed by adding the following line at the end of your `php-fpm.conf` file and restarting PHP FPM. If you're unsure where the `php-fpm.conf` file is located you can check `phpinfo()`. If you are using Laravel Valet the `php-fpm.conf` file will be located in the `/usr/local/etc/php/YOUR-PHP-VERSION` directory.

```
env[PATH] = /usr/local/bin:/usr/bin:/bin

```

This will instruct PHP FPM to look for the `gs` binary in the right places.

Testing
-------

[](#testing)

```
$ composer test
```

Changelog
---------

[](#changelog)

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

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.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/spatie)
- [All Contributors](../../contributors)

Support us
----------

[](#support-us)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 79.5% 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 ~82 days

Recently: every ~327 days

Total

29

Last Release

1660d ago

Major Versions

0.0.1 → 1.0.02015-07-02

1.4.0 → v2.x-dev2017-06-20

1.8.1.2 → 2.12021-11-01

PHP version history (4 changes)0.0.1PHP &gt;=5.5.0

v2.x-devPHP ^7.0

1.8.1.2PHP ^7.0|^8.0

2.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2249564?v=4)[steffen-99](/maintainers/steffen-99)[@Steffen-99](https://github.com/Steffen-99)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (89 commits)")[![Steffen-99](https://avatars.githubusercontent.com/u/2249564?v=4)](https://github.com/Steffen-99 "Steffen-99 (4 commits)")[![christophe-mailfert](https://avatars.githubusercontent.com/u/8286816?v=4)](https://github.com/christophe-mailfert "christophe-mailfert (2 commits)")[![BenjaminRehn](https://avatars.githubusercontent.com/u/2428038?v=4)](https://github.com/BenjaminRehn "BenjaminRehn (1 commits)")[![dsinn](https://avatars.githubusercontent.com/u/5075438?v=4)](https://github.com/dsinn "dsinn (1 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (1 commits)")[![introwit](https://avatars.githubusercontent.com/u/11228182?v=4)](https://github.com/introwit "introwit (1 commits)")[![jamesdb](https://avatars.githubusercontent.com/u/6299056?v=4)](https://github.com/jamesdb "jamesdb (1 commits)")[![michael-wolfram](https://avatars.githubusercontent.com/u/16456767?v=4)](https://github.com/michael-wolfram "michael-wolfram (1 commits)")[![miclf](https://avatars.githubusercontent.com/u/3188746?v=4)](https://github.com/miclf "miclf (1 commits)")[![Philhil](https://avatars.githubusercontent.com/u/1251902?v=4)](https://github.com/Philhil "Philhil (1 commits)")[![robert197](https://avatars.githubusercontent.com/u/10999294?v=4)](https://github.com/robert197 "robert197 (1 commits)")[![TVke](https://avatars.githubusercontent.com/u/15680337?v=4)](https://github.com/TVke "TVke (1 commits)")[![WinterSilence](https://avatars.githubusercontent.com/u/3521094?v=4)](https://github.com/WinterSilence "WinterSilence (1 commits)")[![wqj97](https://avatars.githubusercontent.com/u/18662395?v=4)](https://github.com/wqj97 "wqj97 (1 commits)")[![zaherg](https://avatars.githubusercontent.com/u/27624?v=4)](https://github.com/zaherg "zaherg (1 commits)")[![abarta](https://avatars.githubusercontent.com/u/26660567?v=4)](https://github.com/abarta "abarta (1 commits)")[![zandzpider](https://avatars.githubusercontent.com/u/321691?v=4)](https://github.com/zandzpider "zandzpider (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (1 commits)")

---

Tags

spatiepdfconvertimagepdf-to-image

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/steffen-99-pdf-to-image/health.svg)](https://phpackages.com/packages/steffen-99-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)
