I hope this question fits here. I would have asked on Stackoverflow, but there is a similar question there that was closed with the suggestion to ask at Server Fault, and Server Fault closed my question with the suggestion to ask here (which is extremly frustrating):
I need to automatically compress images (uploaded by users) so Google Page Speed Insights doesn't complain about the image size anymore. Using the Google Page Speed Mod for Apache/Nginx is not an option.
I looked at the official image compression FAQ here: https://developers.google.com/speed/docs/insights/OptimizeImages.
They suggest jpegtran and jpegoptim for jpeg images. I tried both with various different settings, but they didn't compress the images any further, and sometimes the images actually got bigger.
Then I tried Guetzli, a new jpeg encoder from Google itself: https://github.com/google/guetzli.
This did compress the images much better than before, but Page Speed Insights still complains that the images are to big.
So how can I compress (hundreds of) Jpegs automatically (on a linux machine) so Google Page Speed Insights doesn't complain anymore?
Edit: To clarify: Google Insights allows you to download optimized images, and they really are much smaller than anything I am able to produce. How can I compress the images (slight quality loss is okay) so they are as small as the images I can download from Google Insights? Since there are hundreds of images on the site using Google Insight to compress them all isn't really practical.
Are there any command line tools for linux that will compress as well as Google Insight?
(There is a protected question on stackoverflow from 2011 but none of the answers work anymore: https://stackoverflow.com/questions/5451597/how-does-googles-page-speed-lossless-image-compression-work?rq=1)