Mahesh Mahesh - 3 months ago 21
Node.js Question

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

https://github.com/jwagner/smartcrop-cli


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

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