rflynn / imgmin

Lossy image optimization
MIT License
650 stars 32 forks source link

Use interpolation/extrapolation instead of bisection #39

Open kornelski opened 10 years ago

kornelski commented 10 years ago

https://github.com/pornel/imgmin/compare/pornel:0fe0e25...pornel:d0b9172

Instead of searching for quality using bisection method, which is slow, I'm trying to find exact quality needed by modelling jpeg quality vs dssim ratio as a curve, and finding the desired point on that curve.

I think I've told my math teacher that polynomials are stupid and I'm never going to use them… but…

The curve is a polynomial constructed from 3 points, and the points represent jpeg-quality to dssim relationship from the last 3 runs (default points are used for the first couple of runs).

It needs a bit of tweaking, but when it works it finds exact quality in 3-4 steps.