gunantos / pdftoimage-php

PHP library PDF to image using Imagick

Home Page:https://app-kita.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PDF TO IMAGE

PHP Composer Discord Travis (.org) GitHub branch checks state Bitbucket Pipelines

Pdf to image library using Imagick

Installation

  • composer composer install appkita/pdftoimage
  • download Github

NEW Version 3.0 (BETA)

  • add convert using ghostscript

INSTALLATION EXTENSION

  1. Windows a. Ghostscript download from ghostscript 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
    • 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
      $image = new Imagick();
      $image->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

    • Imagick

      • Centos
          sudo yum install php-imagick
          php -m | grep imagick
      • Debian
        sudo apt-get install php-imagick
        php -m | grep imagick

Use

 $file = '<<pdf file>>';
 //or
 $file = 'URL FILE';
 //configuration
 $option = [
   'path' => '<<result 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 = '<<your 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
  1. URL

Lear More

Chat

Discord

Sponsor

Pay Coffe

About

PHP library PDF to image using Imagick

https://app-kita.com


Languages

Language:PHP 99.5%Language:HTML 0.5%