You are not logged in.

#1 2014-04-16 13:17:33

epaaj
Member
Registered: 2011-08-10
Posts: 6

Apache/PHP - Problem with shell_exec - ImageMagick - convert

Hi,

I have a problem with running external commands from a webpage written in php using Apache. In this case I'm trying to run convert, which is a program in ImageMagick.
I can run most commands without any problems but when running these I get errors.

shell_exec("/usr/bin/convert -alpha Set -filter bessel -resize '200'x'200' -density '200'x'200' 'image.eps' -channel A -fx 'B' -negate '/var/im/4.png' 2>&1");

shell_exec("/usr/bin/convert 'image.eps' -alpha Set -filter bessel -channel A -fx 'B' -negate '/var/im/4.png' 2>&1");
shell_exec("/usr/bin/convert '/var/im/4.png' -density '200'x'200' -resize '200'x'200' '/var/im/5.png' 2>&1");

Error:

convert: Error when saving the profile into a file '.' @ warning/opencl.c/autoSelectDevice/2303. 

The first command generates the new image but it is incorrect. The two others together gives me an output which looks correct but I still get the errors.
Running either of these commands directly via shell works great and generates the correct output and no error messages.

I would guess that the issue is how Apache handles the execution of shell_exec and the user that is used to run Apache. There is probably some restrictions that creates the issue but I'm note sure what.
I have tried running Apache using a new user I created which can run the commands correct directly in shell or by running "php -f testfile.php" but not through a webpage via Apache.

Any suggestions?

I also asked in the ImageMagick forum if anyone wants to check that they think so far.
http://www.imagemagick.org/discourse-se … =1&t=25418

Offline

Board footer

Powered by FluxBB