PHPackages                             break-down/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. break-down/pdf-to-image

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

break-down/pdf-to-image
=======================

Convert a pdf to an image

0.0.5(7y ago)418MITPHPPHP &gt;=5.6.32

Since Aug 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/break-down/pdf-to-image)[ Packagist](https://packagist.org/packages/break-down/pdf-to-image)[ Docs](https://github.com/break-down/pdf-to-image)[ RSS](/packages/break-down-pdf-to-image/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (7)Used By (0)

Convert a PDF to an Image
=========================

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

A wrapper around Imagick to ease out conversion of PDF file to a JPEG/JPG image.

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 break-down/pdf-to-image
```

Usage
-----

[](#usage)

Converting a pdf to an image is easy.

```
$pdf = new BreakDown\PdfToImage\PdfToImage(new BreakDown\PdfToImage\Resources\FilePath($pathToPdfFile));
$pdf->savePageAsImage($pageNumber, $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
```

You can override the output format:

```
$pdf->setOutputFormat('png')
    ->savePageAsImage($pageNumber, $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()`.

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

```

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

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

2836d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61873cc2e3e5331e13c2dc80f5c32d774da81f1b07fc735df9ff3cde26c6cc5d?d=identicon)[syedhaiderabbas](/maintainers/syedhaiderabbas)

---

Top Contributors

[![syed-haider-abbas](https://avatars.githubusercontent.com/u/1918621?v=4)](https://github.com/syed-haider-abbas "syed-haider-abbas (16 commits)")

---

Tags

pdfconvertimagepdf-to-imagebreakdown

### Embed Badge

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

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