I read this looking to see if there was anything we could adapt for mod_pagespeed. Making images smaller without looking worse is, of course, what anyone optimizing images wants. Unfortunately, all they say about how they actually did their perceptual compression is:<p><pre><code> Ideally we’d have an algorithm which automatically tuned
all JPEG parameters to make a file smaller, but which
would limit perceptible changes to the image. Technology
exists that attempts to do this and can decrease image
file size by 30-50%.
</code></pre>
As far as I know, the only practical way to do this is to do a binary search for the quality level that gives a desired SSIM [1], but this is kind of expensive and I was hoping that they had something cool to tell us here.<p>[1] If you're interested in getting this kind of improvement and your images are viewed enough that it's worth doing more intensive encoding to get things exactly right, you could do this:<p><pre><code> def evaluator(image, candidate_quality):
compressed = jpeg_compress(image, candidate_quality)
return dssim(image, compressed)
best_quality = binary_search(
image, desired_dssim, candidate_qualities, evaluator)</code></pre>