https://github.com/gunantos/pdftoimage-php
PHP library PDF to image using Imagick
https://github.com/gunantos/pdftoimage-php
ghostscri image imagick imagickphp library pdf pdflib pdftoimage php
Last synced: 3 months ago
JSON representation
PHP library PDF to image using Imagick
- Host: GitHub
- URL: https://github.com/gunantos/pdftoimage-php
- Owner: gunantos
- Created: 2021-05-23T13:06:17.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-15T04:51:23.000Z (almost 4 years ago)
- Last Synced: 2025-01-13T07:13:02.359Z (5 months ago)
- Topics: ghostscri, image, imagick, imagickphp, library, pdf, pdflib, pdftoimage, php
- Language: PHP
- Homepage: https://app-kita.com
- Size: 234 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# PDF TO IMAGE
[](https://github.com/gunantos/pdftoimage-php/actions/workflows/php.yml)




Pdf to image library using ImagickInstallation
- composer
`composer install appkita/pdftoimage`
- download [Github](https://github.com/gunantos/pdftoimage-php/releases)## NEW Version 3.0 (BETA)
- add convert using ghostscript
### INSTALLATION EXTENSION
1. Windows
a. Ghostscript
download from [ghostscript](https://www.ghostscript.com/download/gsdnld.html)
add your gs bin folder to PATH Environment
b. Imagick- Check PHP Version `php -i|find "PHP Version"`
- Check PHP is Thread Safety `php -i|find "Thread Safety"`
- Check PHP Architecture `php -i|find "Architecture"`
- Download imagick from [Imagick](https://pecl.php.net/package/imagick)
- Once you downloaded the correct files:
- Extract from `php_imagick-….zip` the `php_imagick.dll `file, and save it to the ext directory of your PHP installation
- Extract from `ImageMagick-….zip` the DLL files located in the bin folder that start with `CORE_RL` or `IM_MOD_RL`, and save them to the PHP root directory `(where you have php.exe)`, or to a directory in your PATH variable
- Add this line to your `php.ini` file: `extension=php_imagick.dll`
- Restart the Apache/NGINX Windows service (if applicable)
- To test if the extension works, you can run this PHP code:
```php
newImage(1, 1, new ImagickPixel('#ffffff'));
$image->setImageFormat('png');
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed';
```2. Linux
- Ghostscript
download from [ghostscript](https://www.ghostscript.com/download/gsdnld.html)
- Imagick- Centos
```sh
sudo yum install php-imagick
php -m | grep imagick
```
- Debian```sh
sudo apt-get install php-imagick
php -m | grep imagick
```### Use
```php
$file = '<>';
//or
$file = 'URL FILE';
//configuration
$option = [
'path' => '<>', //default empty
'format' => 'png', //set image format output
'resolution' => 'set resultion image',
'prefix'=> 'convert', //set prefix name image
'layer_method'=>Imagick::LAYERMETHOD_FLATTEN, //follow Imagick Layer Method
'colosrpace'=> null, //follow Imagick colorspace
'quality'=> null, //follow imagick result quality
];
$spesific_page = null;
$convert = new \Appkita\PDFtoImage\Convert($file, $option);
$result = $convert->run(); //set null if you wont
//or
$result = $convert->run($spesific_page);/**
* Or
*/
$convert = new \Appkita\PDFtoImage\Convert($file);
$convert->path = '<>';
$convert->format = 'jpg';
$convert->run($spesific_page);
/**
* Or
*/
$convert = new \Appkita\PDFtoImage\Convert();
$result = $convert->setFile($filepdf)->run($spesific_page, $options); // if is_string $options return $path output
```2. URL
### Lear More
- [php](https://www.php.net/manual/en)
- [Imagick](https://www.php.net/manual/en/book.imagick.php)'
- [Ghostscript](https://www.ghostscript.com/download/gsdnld.html)### Chat
[Discord](https://discord.gg/bXUWCSaw)
### Sponsor
[Pay Coffe](https://sponsor.app-kita.net)