I have installed ImageMagick on Windows with the DLL for imagick PHP.

I need to convert PDFs into JPEGs. So I also installed Ghostcript.

If I run this command:

convert rose.pdf rose.jpg 

it works well. But if I try to reproduce this same functionality in my web environment with PHP:

$im = new imagick('test_pdf.pdf[0]' ); 

$im->setImageColorspace(255);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(100);
$im->setImageFormat('pdf');
$im->writeImage('thumb.jpg');

then my page goes down.

I assume that Imagick PHP fails with PDF to JPEG, because it doesn't know how to use the Ghostscript library gslib.

With this code, however, I can convert PNG to JPEG.

I tried to edit in delegates.xml but I'm not exactly sure how this should be done.

Here are the relevant lines from my delegates.xml:



Perfect converting PDF to jpg

Answers

Here are the relevant lines from my delegates.xml. I do however not use Imagick nor PHP, so I'm not sure it's the only change you need to make in order to make it work.

First, a form that lets you read it without horizontal scrolling. You have to remove the line breaks as well as the line continuation characters \ which I inserted:



Now the original lines. You need to scroll horizontally to see it fully and in its original shape:


These lines are from my Mac OS X version of ImageMagick, 6.9.0-0 Q16 x86_64

As you can see, it doesn't use a @PSDelegate-syntax. Instead it contains the full path to the Ghostscript executable, in my case /opt/local/bin/gsx.

For your case, it should possibly be the full Windows path to your Ghostscript executable, which usually is named gswin32c.exe or gswin64c.exe.

Your problem with the strange @PSDelegate possibly comes from the fact that you installed ImageMagick/Imagick before you installed Ghostscript, and installed Ghostscript only afterwards

Maybe you should try for your Windows/Ghostscript installation the following lines in your delegates.xml file:


Note, you do not need to use backslashes ('\') -- Ghostscript and ImageMagick are just fine with forward slashes ('/') on Windows.