iwek iwek - 11 months ago 44
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?


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.