4 ms·
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 optim
by cbr 11y ago
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:
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%.
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.
[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:
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)
- tambourine_man 11y agohttps://github.com/technopagan/cjpeg-dssim https://github.com/technopagan/cjpeg-dssim
- tomkwok 11y agoimgmin: https://github.com/rflynn/imgmin https://github.com/rflynn/imgmin
- tambourine_man 11y agoNice. I've been using Jpegoptim for years. Do you know if it uses a similar strategy to imgmin?
- pornel 11y agoimgmin and jpegoptim are orthogonal. imgmin finds the lowest-good quality, and jpegoptim optimizes compression at that quality.
- pornel 11y agoYou can use interpolated bisection instead of a straight one (I've tried using polynomial interpolation in imgmin and it saves a step or two). I also wonder whether it would be possible to narrow down the range with only a sample of the image (i.e. pick "representative" subregion(s), bisect on that, then try that quality on the whole image).
- ZeroGravitas 11y agoThere's tools like JpegMini, which tries to detect when artifacts become annoying. There's an open source re-implementation of their published algorithm on github, but they have patents, which might be part of Flickr's reticence: https://github.com/dwbuiten/smallfry https://github.com/dwbuiten/smallfry