php imagick error when pdf involved

2

When I try to convert the first page of a PDF into JPG through PHP imagick, I get an HTTP 500 error with no log in php_errors.log.

Explanation from IIS: The FastCGI process exited unexpectedly

Error code: 0xc0000417

Two files are created in C:\Windows\Temp, the first one is the PDF read; the other is 0 Kb length.

I am able to perform command line conversions with ImageMagick (convert some.pdf some.jpg). So, ImageMagick and GhostScript are running fine. Also, I am able tho convert between JPG and GIF from PHP scripts.

PHP code:

$im = new Imagick();
$im->setResolution(300,300);
$im->readimage('poster.pdf[0]'); 
$im->setImageFormat('jpeg');    
$im->writeImage('poster.jpg'); 
$im->clear(); 
$im->destroy();

My environment:

  • Windows 7 Professional 64 bit
  • IIS 7.5
  • PHP 5.3.6 NTS VC9 via FastCGI
  • PHP imagick extension v.3.1.2 (5.3 NTS VC9 x86, from PECL)
  • ImageMagick-6.7.7-0-Q16-windows-dll (x86)
  • GhostScript 9.07 win32 (x86)
  • Microsoft Visual C++ 2008 redistributable x86
  • Path to ImageMagick added to PATH environment variable
  • Permissions granted to IUSR and IIS_IUSRS in folders C:\Windows\Temp and C:\imagemagick.

So, can anyone give me some guidance to debug this error and have the thing running?

php
pdf
iis-7.5
imagick
asked on Stack Overflow May 18, 2015 by Laura • edited May 18, 2015 by Laura

1 Answer

1

As Danack suggested, ImageMagick MUST be downloaded from the same place imagick was. Compiler version and processor architecture must be respected to match the ones of PHP and GhospScript (in my case, VC9, x86).

Nevertheless, not all versions of ImageMagick availables at this repository appear to be consistent with those of imagick and / or GhostScript. In my case, the combination that finally worked (at second attempt) was:

  • imagick 3.1.2
  • ImageMagick 6.8.8
  • GhostScript 9.07
answered on Stack Overflow May 19, 2015 by Laura

User contributions licensed under CC BY-SA 3.0