magickException: Postscript delegate failed IIS

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

magickException: Postscript delegate failed IIS

Post by Namari »

Hey Guys!

I'm trying to use theses lines to convert a pdf to a jpg but I got an error

Code: Select all

$img = new imagick($url.'[0]');
$im->setImageColorspace(255);
$im->setCompressionQuality(95);
$im->setImageFormat('jpeg');
I have install imagick 3.1.0RC2 with the soft ImageMagick 6.7.7-10 2012-06-27 Q16 (x86). I also have a x86 PHP 5.4.22 non thread and I'm using IIS 8 on a windows server 2012. The php_imagick.dll is for 5.14 nts so it should work. The ghostscript version is gs9.10, I installed 32 and 64 bits. it is working perfectly with the msdos command line but no with PHP.

and then I got this error when I create the object.

Code: Select all

ImagickException: Postscript delegate failed `D:\inetpub\website\sites\default\files\image_2.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/677 in Imagick->__construct()
is it an environment variables problem ? I've got the imagick folder and the bin folder of ghostscript as windows environment variable.
Any ideas ?

Cheers
Last edited by Namari on 2014-01-06T21:24:50-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: magickException: Postscript delegate failed IIS

Post by snibgo »

It can't find the PDF in a relative path, but relative to where? You might try an absolute path.
snibgo's IM pages: im.snibgo.com
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by Namari »

the path I gave him was D:\inetpub\website\sites\default\files\image_2.pdf I also tried the url but no success.
for the url http://mywebsite/sites/default/files/image_2.pdf it gives me :

Code: Select all

ImagickException: Unable to read the file: http://mywebsite/sites/default/files/image_2.pdf in Imagick->__construct()
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by Namari »

anyone ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: magickException: Postscript delegate failed IIS

Post by fmw42 »

Try a file of another format, such as gif, jpg, png. Does that work? If so, the perhaps it is not finding Ghostscript or the directory is password protected? Or try getting an image from some other more common web site, such as google or yahoo. Does that work?
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by Namari »

It seems that it's not finding ghostscript :(
It is working if I'm using a shell_exec(gswin64 ...) but that's not what I'm looking for.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: magickException: Postscript delegate failed IIS

Post by fmw42 »

check phpinfo.php

You may have to configure PHP so that it can find ghostscript.
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by Namari »

I'm not sure there is something I can do in php.ini.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: magickException: Postscript delegate failed IIS

Post by snibgo »

Have you tried putting the full path to GS in delegates.xml?
snibgo's IM pages: im.snibgo.com
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by Namari »

I changed the code below by the other one but nothing :(

Code: Select all

<delegate decode="eps" encode="pdf" mode="bi" command=""@PSDelegate@" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -sDEVICE=pdfwrite "-sOutputFile=%o" -- "%i""/>

Code: Select all

  <delegate decode="eps" encode="pdf" mode="bi" command='"C:\Program Files (x86)\gs\gs9.10\bin\gswin32.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -sDEVICE=pdfwrite "-sOutputFile=%o" -- "%i"'/>
Namari
Posts: 7
Joined: 2014-01-06T20:52:41-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by Namari »

I finally found out what was the problem !
The problem is the temporary folder of windows (c:\windows\temp) has to be read and write for the user IUSR or IIS_IUSRS (depending of your ISS version) Thank you guys for your help
ncrause
Posts: 2
Joined: 2014-04-17T22:53:44-07:00
Authentication code: 6789

Re: magickException: Postscript delegate failed IIS

Post by ncrause »

I had precisely the same issues describe in this thread, and Namari's final solution (changing file permissions on C:\Windows\Temp) resolved the problem. Much appreciated!
Post Reply