What is exec, and why do I need it?
Before we get too deep in the details, we have some great news!
In 2020, we started allowing anyone using EWWW IO on an "exec-deprived" server to use our cloud-based compression API for free. Yes, free! But of course we have to set some reasonable limits, because the API costs a lot of money to maintain.
So here's the scoop! You may use the compression API with these limitations (below), or start a premium trial to see what EWWW IO can really do:
- JPG only. Other formats, like PNG, GIF, and PDF are available on paid plans.
- Free WebP conversion is included, but WebP delivery is much simpler with our Easy IO CDN.
- Lossless (Pixel Perfect) compression only. Premium compression naturally requires purchase of a premium product.
- No backups of images. Without an API key, we have no way to keep your image backups separate from anyone else's images. And the free compression is lossless anyway, so you don't really need backups.
There are zero limits on file size or the number of images you can compress. Our mission is to make image optimization accessible for everyone. So, if you can afford it, please help us in this effort by financially supporting EWWW IO.
Now, for those of you who like all the technical details, or if you really, really want to use free server-based compression, read on!
Why does EWWW IO need exec()?
First of all, the reason there are image optimization plugins is that PHP is bad at compressing images. If it were not so, someone would just write a nifty PHP function to compress your images, and we would all move on our merry way.
To optimize images, then, we need something outside of PHP. Most plugins simply send your images to a third-party server, run the optimization on their server, then send the image back. This is cloud-based compression, and PHP does this easily on pretty much any web host. You can certainly do that with EWWW IO as well. In fact, I recommend it if you want to really make your site fast. Lossless compression will only get you so far, but lossy compression takes things to a whole different level.
But I digress, you wanted to know about 'exec', right?
To optimize your images right on your own server, without sending them somewhere else, we need some extra tools outside of PHP. EWWW IO uses tools like jpegtran, optipng, gifsicle, and others, but those are command-line tools, so how does PHP talk to a command-line tool? PHP can use several different functions, but 'exec' is the one used by EWWW IO. So the reason EWWW IO needs 'exec' is to allow PHP to run command-line tools on your server.
If you've seen a warning about exec() being disabled, you may wonder, "why would anyone disable exec?"
The simple answer is that exec can represent a security problem. It is very difficult to use the exec function correctly without opening up security holes. Thus many web hosts prefer not to trust random guys on the Internet to use exec correctly. Anything that is sent to the exec function needs to be sanitized, and escaped, and it isn't always easy to remember that. Indeed, it is something that I regularly have to check for in EWWW IO's code.
So, can you enable 'exec'? That depends greatly on your hosting environment. If you manage your own server, it is as simple as removing 'exec' from the disable_functions setting in your php.ini file. If you leave that arduous task to your web host, then you cannot override it with a custom php.ini. If exec is disabled at the server level, the only one who can enable it is the "system administrator". In other words, you're at the mercy of your web host here. Ask them, very nicely, if they will enable the exec function so that you can use the EWWW Image Optimizer to make your images smaller, use less space, and less bandwidth.
If you cannot enable 'exec', do not fret, EWWW IO can still make your images smaller using cloud-based methods!