I am on Mac OS X 10.9.4
I can run this command successfully from the command line to produce an image or google.com
wkhtmltoimage http://www.google.com /Users/me/Sites/google.jpg
But when I tried to execute the same command from inside my website using the php command
$cmd='wkhtmltoimage http://www.google.com /Users/me/Sites/google.jpg';
shell_exec($cmd);
I get the following error:
sh: wkhtmltoimage: command not found
Is this a permission issue? If so how can I get it to work?
====
I set the full path like @Mureinik suggested and I made some progress now the error message I get is
Loading page (1/2)
[> ] 0%
[======> ] 10%
[=============> ] 23%
[==================> ] 31%
[===================> ] 33%
[========================> ] 41%
[=====================================> ] 62%
[=======================================> ] 65%
[========================================> ] 67%
[=========================================> ] 69%
[==========================================> ] 71%
[==============================================> ] 78%
[==================================================> ] 84%
[===================================================> ] 86%
[============================================================] 100%
Rendering (2/2)
[> ] 0%
[===============> ] 25%
Error: Could not write to output file
Error: Could not save image
[============================================================] 100%
Done
Exit with code 1, due to unknown error.
Am I having a permission issue now?
====
I changed the file permission to my destination and that took care of it.
The issue is probably that shell_exec
uses a different $PATH
then you, and thus can't locate wkhtmltoimage
.
From you own shell, you can use which wkhtmltoimage
to determine where exactly it's installed, and then use shell_exec
with the full path, e.g.:
$cmd='/opt/wkhtmltoimage http://www.google.com /Users/me/Sites/google.jpg';
shell_exec($cmd);