Mahesh Mahesh - 1 year ago 132
Node.js Question

smartcrop-cli - How can i execute it with php exec?

After installing smartcrop, i can execute

/usr/bin/smartcrop --width 100 --height 100 photo.jpg square-thumbnail.jpg

in my terminal and it works good. It is a node module and i am not sure whether it can be accessed with php's exec.

when i try

exec('/usr/bin/smartcrop --width 100 --height 100 photo.jpg square-thumbnail.jpg')

it is not working. How to use smartcrop cli with php.

Answer Source

First, try running your script in php from the commandline (instead of from the browser):
something like: $ php -f script.php.
Sometimes the problem is with permissions.

In the script, I would use:
exec('nohup /usr/bin/smartcrop --width 100 --height 100 photo.jpg square-thumbnail.jpg &');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download