Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 737
iwek Avatar asked Feb 14 '12 14:02

iwek


Video Answer


2 Answers

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.

like image 178
Appleman1234 Avatar answered Sep 20 '22 05:09

Appleman1234


ImageOptim is no longer OS X-only. Now you can use the ImageOptim Web API on any platform.

like image 21
Kornel Avatar answered Sep 23 '22 05:09

Kornel