Search code examples
phpimagemagickghostscriptimagicklaragon

PDF functionality not working with imagick using Laragon


I'm currently trying to convert PDF pages to images using Imagick however, I get the following error below:

PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794

I believe this is because ImageMagick is not detecting my GhostScript installation.

I know Imagick is working fine as I have been able to manipulate other image files with it.

I also know ImageMagick and GhostScript are working on my system (windows) as when I run ImageMagick through the windows CMD, i am able to convert pdf pages to images. It is only when I try to use ImageMagick via Imagick that the error occurs.

To get Imagick working with PHP in Laragon, I followed the guide here. Part of this guide was to copy the ImageMagick Dlls from here into the root PHP folder which Laragon uses.

I believe PHP is using the version of ImageMagick which I have put into the PHP folder rather than the working version of ImageMagick which my system uses which is installed in C:\Program Files\ImageMagick-7.0.10-Q16-HDRI rather than in C:\laragon\bin\php\php-7.4.10-Win32-vc15-x64

I have set the correct ImageMagick and GhostScript paths in my PATH environment variables with no luck.

Is it possible to set Imagick to use a different installation of ImageMagick or at least detect my GhostScript installation?


Solution

  • Figured it out. Install ImageMagick using the installer from the official website (https://imagemagick.org/script/download.php) and then move all the files into your PHP installation folder.