Page 1 of 1

PHP IIS Convert pdf to jpg

Posted: 2009-11-13T04:46:22-07:00
by susana
Hello,
I have installed a web server over W2003Server+IIS+PHP
I have installed ImageMagic and GhostScript and from command promp i can execute this instruction convert label_signed/1-label.pdf label_signed/1-label.jpg and it work fine, but then i try to execute it from php code and it don't work

<?php
$result=exec("convert label_signed/1-label.pdf label_signed/1-label.jpg");
?>
Could somebody helpme, please?

Re: PHP IIS Convert pdf to jpg

Posted: 2009-11-13T10:50:57-07:00
by fmw42
you generally need to provide the full path to convert, usually /usr/local/bin/convert

try this and see if you get the IM version information

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

for more information about using IM with PHP exec, see http://www.rubblewebs.co.uk/index.php

Re: PHP IIS Convert pdf to jpg

Posted: 2009-11-23T16:26:43-07:00
by Wkidd
Hello fmw42,

Please check the question. It's a problem with W2003 Server+IIS+PHP, not with linux or other environments.
I think it's a big bug or the imagemagick doesn't support IIS.

Re: PHP IIS Convert pdf to jpg

Posted: 2009-11-23T16:44:22-07:00
by fmw42
I don't know anything about IIS or windows. BUT I do know that if it works in command line (as she says) and NOT in PHP, then often with PHP you have to give the full path to convert, unless you have set up your environment to know how to get to convert. I have no idea what the full path to convert will be in Windows environment. But often if you run

convert -list configure

you may find that out (at least in part) from the PREFIX line.

Perhaps some Windows/PHP expert can provide more details on how to set up the Windows environment for running IM with PHP.

Re: PHP IIS Convert pdf to jpg

Posted: 2009-11-23T20:40:49-07:00
by Wkidd

Code: Select all

Command Line
C:>Convert -density 300 test.pdf test.jpg      ' OK
It works on command line but not on program in IIS6.0.
I think the problem is a security restriction in IIS.

Re: PHP IIS Convert pdf to jpg

Posted: 2010-07-19T12:33:10-07:00
by mqualls
I am having a similar issue.

IIS 6.0
PHP 5.2.13
ImageMagick with PHP exec command

convert works via command line, but does not work via PHP and does not return an error message ... has anyone else run across this issue? Solution?

This is sample code:

Code: Select all

$exec_image = 'C:\ImageMagick\convert ' .$_SERVER['DOCUMENT_ROOT'].'/mq_dev/NCPR080411.pdf '.$_SERVER['DOCUMENT_ROOT'].'/mq_dev/NCPR080411.jpg';

exec($exec_image, $return_code);

echo $return_code;

Re: PHP IIS Convert pdf to jpg

Posted: 2010-07-19T17:00:49-07:00
by fmw42
Include the $out and print_r as above and see if that tells you what is wrong.

I don't know much about Windows, but perhaps your full path to IM is incorrect?

Re: PHP IIS Convert pdf to jpg

Posted: 2010-07-21T06:59:54-07:00
by mqualls
There is not any message written to the screen ... the result array is empty and the out result code is a '1' - failure ... but no error message ...

I am currently trying with ImageMagick-6.6.3-0-Q8 ...

I have tried several different versions of imagemagick all with similiar levels of failure ... it always works from the command line ... never from PHP ... always an empty result array ...

I have read articles and articles and articles across the Web and all of them say that my stuff should be working and it just doesn't ...

My thought is that if noone really knows how imagemagick works on Windows then the Org should stop providing a Windows version ... or at least put in a disclaimer that it is not meant to work with PHP on Windows ...

BTW, IMagic and MagicWand don't work either ... I add those (either one) to my extensions dir ... update my INI file ... restart ... and nothing ... PHP never sees either extension ... Maybe somebody has experience with IMagic or MagicWand on Windows 2003/IIS6.0/PHP 5.2.13?

Any help appreciated.

Re: PHP IIS Convert pdf to jpg

Posted: 2010-07-21T09:12:23-07:00
by snibgo
I notice you have mixed forward and backward slashes. Is this okay in PHP? I don't know, but it wouldn't work as a command line.

You might try executing a command in PHP exactly as you would type it (without variables, etc).

You might also try making a trivial C utility, put that in the ImageMagic directory, and see if that works in PHP.

Re: PHP IIS Convert pdf to jpg

Posted: 2010-07-21T10:41:45-07:00
by mqualls
Tried full directory path with backslashes to no avail ...

uninstalling my current version of imagemagick and going back to version ImageMagick-6.4.1-0-Q8 (I had run across an article previously which suggested something like this) .... that was of no avail.

All still works from the command line ...

Re: PHP IIS Convert pdf to jpg

Posted: 2011-08-31T09:03:18-07:00
by andyknas
I'm having the same issue with the latest build and IIS6 on Win 2003. When I echo the command line, copy and paste it into terminal and it works properly.

Steps I took:
- Adjusted CMD.exe perms to include IUSR_*
- Adjusted perms for convert.exe in IM folder to include IUSR_* execute perms
- Renamed convert.exe in IM folder to alternate name due to collision with convert.exe in System32 folder (originally got error about param)

Trying commands like DIR from PHP Exec all work as expected.

... Frustrating

Re: PHP IIS Convert pdf to jpg

Posted: 2011-08-31T09:31:32-07:00
by andyknas
For kicks, I installed irfanview as I found it has some command line support. Having the same issue with it, I can run a conversion from command line but it doesn't execute when called from PHP.

...Next workaround is to try running a batch file to call IM. Ugh.

Re: PHP IIS Convert pdf to jpg

Posted: 2011-09-01T06:36:48-07:00
by andyknas
So the issue seems to have been permissions. I was able to get both IM and irfanview to work by adjusting perms at the folder level of the exe (applied to all items, not just the exe)

http://www.iis-aid.com/articles/how_to_ ... magick_iis

Re: PHP IIS Convert pdf to jpg

Posted: 2015-03-06T04:59:36-07:00
by antonlashan
install the ...windows-x64-static.exe
this work for me

http://www.imagemagick.org/download/bin ... static.exe

Re: PHP IIS Convert pdf to jpg

Posted: 2015-06-29T03:42:20-07:00
by niyas
I can compress a .jpg through browser as well as command prompt... but i can't convert a pdf to jpeg through browser . getting error Last OS error: No such file or directory..

System config
............................
windows server2008R2 and iis
php 5.5.11