Mahesh Mahesh - 5 months ago 25
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.


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 &');