Mobile app version of vmapp.org
Login or Join
Martha676

: How to compress jpeg images for Google Page Speed Insights? I hope this question fits here. I would have asked on Stackoverflow, but there is a similar question there that was closed with the

@Martha676

Posted in: #Compression #GoogleInsights #Jpeg

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):
stackoverflow.com/questions/41313719/google-pagespeed-insights-optimize-images-running-new-image-compression
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: 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: 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: stackoverflow.com/questions/5451597/how-does-googles-page-speed-lossless-image-compression-work?rq=1)

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Martha676

2 Comments

Sorted by latest first Latest Oldest Best

 

@Reiling115

I use Gimp software plus a plugin that allows batch optimizing. The percentage of compression is the tricky part especially for batches. I would test at least one image before doing batches.

10% popularity Vote Up Vote Down


 

@Nimeshi995

Lossless VS Normal Compression

Looks like you're getting your wires mixed, Google insights refers to lossless compression, not the JPEG encoder. jpegoptim, jpegtran, jpegrescan, mozjpeg1, mozjpeg2 and so on are all lossless compression tools, not JPEG encoders such as Guetzli.

What this means is it takes an already compressed file and makes it even smaller by stripping down the things it doesn't need, such as hidden META information.

Effective you are compressing the file twice. Generally the JPEG compression in most imaging software such as Photoshop will do, you just need to compression it again using a lossless application.



Caching Issues

If you have tried jpegtran but still got Google insights nagging at you then it may be caused server-side caching which is still delivering the old version of the image, this is common with content delivery networks and reverse HTTP proxy's.

If you are using aws s3, vanish, CloudFlare or a similar service you will need to purge the cache before testing.



Lossless Compression, Different Results.

You will often find that lossless compression will vary from one image ot the next depending on the software your using, some images compress better in one tool but may not do better in the next and vice versa.

Many people will use a script or application that will run the file in multiple lossless compressions and find the best results, this is particular more useful in PNG than JPEG because the results can actually be more than 5-50kb different.

You will find with lossless compression applications, results vary depending on the image, not the application, so often you have to use an array of lossless compression and pick the best size.

Thankfully there are applications online that will help you do this without having to build your own script and run the image one by one through different compressions, if your a windows user, I recommend that you take a look at FileOptimizer.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme