iwek iwek - 1 year ago 107
Linux Question

How to run imageoptim from php on linux?

I was checking out imageoptim today, and really would love to run this from php on my linux server. Is that possible?

Answer Source

imageoptim is Mac OS X only. On there website they recommend trimage for non Mac users.

In order to call external programs from php you use the exec command documented here.

Note that for security reasons it is important to escape arguments passed to exec with another command like escapeshellcmd or escapeshellarg for security reasons.

Your assumption in the comment about command line options is correct, you just pass them along with the program name as the string argument to exec with proper escaping of course.

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