I am on Win Server 2012 IIS 8, PHP 5.6, Imagick Module 3.1.2, ImageMagick 6.8.7-2 2013-10-18 Q16.
I have read through all the Postscript delegate failed errors and have done the following: - Installed GhostScript - Checked that GS and Imagick is in the PATH var - Checked that I can use convert in the command prompt (Does work) - PHP exec("whoami") returns nt authority\\iusr which I added for Full Control - I tried using full paths backslashes () double-backslashes (\\) foward-slashes (/) - I don't think it has anything to do with the path because if I try the same code on a jpg with no path it works. Script and files are in the same path.
Here is my PHP code:
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
echo exec("whoami"); echo "<br/>";
echo exec("convert.exe dr.pdf dr.jpg 2>&1"); // Does not work and gives below error
echo "<br/>";
$im = new imagick();
$im->readimage("dr.pdf");
$pages = $im->getNumberImages();
echo $pages;
?>
Output:
nt authority\\iusr convert.exe: no images defined `dr.jpg' @ error/convert.c/ConvertImageCommand/3145.
Fatal error: Uncaught exception 'ImagickException' with message 'Postscript delegate failed `dr.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/682' in D:\\WWW\\DEMO\\data\\temp\\test.php:13 Stack trace: #0 D:\\WWW\\DEMO\\data\\temp\\test.php(13): Imagick->readimage('dr.pdf') #1 {main} thrown in D:\\WWW\\DEMO\\data\\temp\\test.php on line 13
Any help would be greatly appreciated. Regards Johan
To anyone who might run into the same problem: Change the permissions of C:\\Windows\\Temp to include Full Control for IIS_IUSRS and Users
After I did this everything seems to work!
Note: I had to upgrade to the latest PECL Imagick Module to see the full error that GhostScript was returning, which showed that GhostScript was trying to perform the conversion in windows Temp folder. It was strange that my php script worked from a command line but not from the website. But obviously it was a permission issue.
I'm posting the following Installation steps for whoever runs into the same problem (Or if I need a guide in the future and I forgot :) ) On Windows 2012 Server with IIS 8
What always helped me is testing my most basic script through a command prompt> php.exe test.php This will almost always show you errors if you did something wrong with the install or if you need a VC Redist. Where a website query doesn't always show you the startup errors.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.