PHP IIS Convert pdf to jpg
PHP IIS Convert pdf to jpg
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?
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?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP IIS Convert pdf to jpg
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
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
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP IIS Convert pdf to jpg
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.
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
Code: Select all
Command Line
C:>Convert -density 300 test.pdf test.jpg ' OK
I think the problem is a security restriction in IIS.
Re: PHP IIS Convert pdf to jpg
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:
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;
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP IIS Convert pdf to jpg
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?
I don't know much about Windows, but perhaps your full path to IM is incorrect?
Re: PHP IIS Convert pdf to jpg
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.
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.
Last edited by mqualls on 2010-07-21T10:42:35-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PHP IIS Convert pdf to jpg
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.
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.
snibgo's IM pages: im.snibgo.com
Re: PHP IIS Convert pdf to jpg
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 ...
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
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
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
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.
...Next workaround is to try running a batch file to call IM. Ugh.
Re: PHP IIS Convert pdf to jpg
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
http://www.iis-aid.com/articles/how_to_ ... magick_iis
-
- Posts: 1
- Joined: 2015-03-06T04:57:31-07:00
- Authentication code: 6789
Re: PHP IIS Convert pdf to jpg
install the ...windows-x64-static.exe
this work for me
http://www.imagemagick.org/download/bin ... static.exe
this work for me
http://www.imagemagick.org/download/bin ... static.exe
Re: PHP IIS Convert pdf to jpg
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
System config
............................
windows server2008R2 and iis
php 5.5.11