PHPackages                             nguyenhiep/pdf2image - 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. nguyenhiep/pdf2image

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

nguyenhiep/pdf2image
====================

Allow you cropping an image from file pdf

014PHPCI failing

Since Dec 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/nguyenhiepvan/pdf2image)[ Packagist](https://packagist.org/packages/nguyenhiep/pdf2image)[ RSS](/packages/nguyenhiep-pdf2image/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

This package provides an easy to work with class to cropping an image from pdf file

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](https://github.com/nguyenhiepvan/pdf2image#issues-regarding-ghostscript).

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

[](#installation)

The package can be installed via composer:

```
composer require nguyenhiep/pdf2image:dev-master
```

Usage
-----

[](#usage)

```
use Nguyenhiep\Pdf2image\Pdf2image;

$instance = new Pdf2image();

$instance->cropImage($pdf,$page,$width, $height, $startX, $startY);
```

the output will be saved in public/images.

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.

Security
--------

[](#security)

If you discover any security related issues, please email [Mr. Hiep Nguyen](mailto:nguyenhiepvan.bka@gmail.com?subject=%5BGitHub%5D%20Problem%20with%20pdf2image) instead of using the issue tracker.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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/5ee7ece29e66e7029d6b12d947a7d9714ae36346f21e92d767cfc797b86949d8?d=identicon)[nguyenhiepvan](/maintainers/nguyenhiepvan)

---

Top Contributors

[![nguyenhiepvan](https://avatars.githubusercontent.com/u/33170716?v=4)](https://github.com/nguyenhiepvan "nguyenhiepvan (12 commits)")

### Embed Badge

![Health badge](/badges/nguyenhiep-pdf2image/health.svg)

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

###  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.0k22](/packages/bkwld-croppa)[marc1706/fast-image-size

fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.

959.4M20](/packages/marc1706-fast-image-size)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[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)

PHPackages © 2026

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