Command wich work in DOS prompt but not in PHP

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
adil@alfasoft.ro
Posts: 24
Joined: 2012-01-10T05:19:23-07:00
Authentication code: 8675308

Command wich work in DOS prompt but not in PHP

Post by adil@alfasoft.ro »

The command
convert "page0006.tif" -background black -deskew 40% +repage -threshold 75%,80% -write mpr:image +delete ( mpr:image -crop 2020x200+0+1346 -scale 2020x1! -bordercolor black -border 1 -trim -write info: ) ( mpr:image -crop 200x2892+910+0 -scale 1x2892! -bordercolor black -border 1 -trim -write info: ) null:

Is working very well in Dos prompt, but same command don't work in PHP with exec (don't return the info:)
Thanks in advance.
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Command wich work in DOS prompt but not in PHP

Post by whugemann »

As far as I remember this problem has been discussed several times over here. It's probably that the PHP script is executed as a different user than you are usually logged on, probably under administrator rights. So you should test your code while being logged on as the administrator and see whether you run into the same problem. A workaround could be that you supply the full path to Convert, i.e. "%PROGRAMFILES%\ImageMagick...\convert.exe" instead of just calling Convert.
Wolfgang Hugemann
adil@alfasoft.ro
Posts: 24
Joined: 2012-01-10T05:19:23-07:00
Authentication code: 8675308

Re: Command wich work in DOS prompt but not in PHP

Post by adil@alfasoft.ro »

It seems that the command is executed but the response is not coming. Same situation on Linux.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Command wich work in DOS prompt but not in PHP

Post by fmw42 »

try adding 2>&1 after the null:

You may also have to put the full path to convert
adil@alfasoft.ro
Posts: 24
Joined: 2012-01-10T05:19:23-07:00
Authentication code: 8675308

Re: Command wich work in DOS prompt but not in PHP

Post by adil@alfasoft.ro »

Thank you guys but is same situation. Any suggestions?
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Command wich work in DOS prompt but not in PHP

Post by whugemann »

Rather often, IM writes textual output to stderr rather than stdout, see http://www.imagemagick.org/Usage/windows/#pitfalls. Fred basically suggests to redirect this output. However, the output of info: is treated no other than other output "images", i.e. it is written to stdout.

If I were you, I would try a simpler command with info: output in PHP, in order to narrow the cause of the error.
Wolfgang Hugemann
Post Reply