Ruzgfpegk / lscache_wp

LiteSpeed Cache for WordPress
http://wordpress.org/plugins/litespeed-cache/
GNU General Public License v3.0
0 stars 0 forks source link

Add support for local image optimization #1

Open Ruzgfpegk opened 4 years ago

Ruzgfpegk commented 4 years ago

From the official website:

We use a combination of several libraries to adjust your images to 85%-90% quality of the original.

During the process, three versions of each image file are generated:

 * yourimage.bk.jpg: the original version of your image.
 * yourimage.jpg: the optimized version of your image, which is what will be shown on your site from now on.
 * yourimage.jpg.webp: is a version of your image saved in a format that is about 25%-34% smaller than jpg (learn more). To automatically serve WebP images to browsers that support them, just set LiteSpeed Cache > Settings > Media > Image WebP Replacement to ON.

How LSCache Optimizes so Effectively

LSCache image optimization uses far more than just these popular libraries: PNGQuant, JPEGOptim and OptiPNG. We take the best of the libraries we use, in order to get the best compression.

This could at least partially be done locally on systems with the relevant binaries already installed (...or compiled) and with the PHP exec command allowed.

Everyone cannot use the current method (sending images to a remote server) due to privacy concerns, internal environments, ...

The easiest tool to use would be cwebp for WebM conversions, with possibly various passes to determine the best one (depending on the image type, a lossless version can be smaller than a compressed one, and the image type preset could help squeeze even more bytes).

As for JPEGs, the best solution would be to use MozJPEG but it should be compiled on most systems beforehand.

Alternatively, libjpeg-turbo (upon which MozJPEG is built) could also be used.

As for Guetzli... yeah, no.

For now I have to understand the plugin's way of doing things before going further, and I don't know if/when I'll be able to do that, but if somebody is interested we can collaborate to do this and make a PR to upstream (they may not want it though).

Ruzgfpegk commented 4 years ago

First I'm going to do a GUI application unrelated to this project: https://github.com/Ruzgfpegk/img-recomp