set a specific quality factor for JPG

last modified on 30 July 2019, by Cédric Louvrier

pingo could set a specific quality factor to target another size/quality ratio. this lossy transformation change the quality factor for the quantization

N: from 1 to 100 — 1: smaller filesize, worse quality — 100: bigger filesize, better quality
pingo -jpgquality=N target
original file: bees.png (170.34 KB): set JPG quality
original pingo -jpgquality=100 pingo -jpgquality=90
bees - original bees - jpgquality100 bees - jpgquality90
170.34 KB 84.79 KB (0.09s) 31.14 KB (0.09s)
dssim - butteraugli 0.00025677 - 0.968556 0.00127481 - 2.089084
pingo -jpgquality=80 pingo -jpgquality=70 pingo -jpgquality=60
bees - jpgquality80 bees - jpgquality70 bees - jpgquality60
20.63 KB (0.09s) 16.12 KB (0.10s) 13.69 KB (0.09s)
0.00240757 - 2.912983 0.00328398 - 3.458278 0.00418151 - 3.837523
pingo -jpgquality=50 pingo -jpgquality=40 pingo -jpgquality=30
bees - jpgquality50 bees - jpgquality40 bees - jpgquality30
11.86 KB (0.10s) 10.31 KB (0.09s) 8.56 KB (0.11s)
0.00512808 - 4.118621 0.00625122 - 4.728684 0.00826710 - 6.329411
pingo -jpgquality=20 pingo -auto
bees - jpgquality20 bees - jpgquality1
7.63 KB (0.12s) 22.69 KB (0.12s)
0.01017129 - 5.955798 0.00225508 - 2.959047

quality controls

pingo could try to estimate how much is the quality factor if you target lossy JPG compression. this factor could be less than pingo's default. in this case, pingo could avoid to process the image data because results have high chance to be bigger (it could however process the file to remove some segments like comments)

original file: station-sample2-q60.jpg automatically skip image processing
original -auto
station - sample 2 q60 station - sample 2 (not processed)
52.72 KB (quality 60) skipped (image data not processed)

compression level

note that the lossless compression level over this transformation can be increased to get smaller filesize by using -sN

N: from 0 to 9 — 0: fast and good compression — 9: slow, but better compression
pingo -jpgquality -sN target