Search code examples
laravelpdfxamppimagickphp-8

PHP Imagick dont work with PDF files in Laravel 8, simple ImagickException


I try to use first time Imagick to convert pdf files to images and it dont work for me. When i try use Imagick with images files, its ok and working fine, problem is with PDF files.

My test php controller:


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Imagick;
class NewspaperController extends Controller
{

    /**
     * @throws \ImagickException
     */
    public function show()
    {
        $imgExt = new Imagick();

        $imgExt->readImage(public_path('storage/uploads/test.pdf'));

       $imgExt->writeImages(public_path('storage/uploads/pdf_image_doc.jpg'), false);

        
        return view('xxx');
    }
}

When i open this in browser i get only "ImagickException" simple error.

ImagickException

I working on local, with:

  • Laravel 8.54
  • Windows 11
  • XAMPP
  • PHP Version 8.0.7

phpinfo():

  • Compiler Visual C++ 2019
  • Architecture x64
  • imagick module version 3.5.1
  • Imagick compiled with ImageMagick version ImageMagick 7.0.7-11 Q16 x64 2017-11-23
  • Imagick using ImageMagick library version ImageMagick 7.0.7-25 Q16 x64 2018-03-04
  • ImageMagick release date 2018-03-04
  • ImageMagick number of supported formats: 240

Can anyone help?


Solution

  • Imagick has a release candidate that fixes this error. We were experiencing the same issue after upgrading to Laravel 8.

    The new release candidate was posted on 11/10/2021 (6 days after this post). https://windows.php.net/downloads/pecl/releases/imagick/3.6.0rc1/