automatic image compression

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

pingo could attempt to do automatic image compression by default. in this case, it could select itself what to perform on image data. if lossy, it should provide a close visual perception from original image by picking itself the quality. if required, the image data could be converted to sRGB colour space automatically

pingo -auto target

RGBA (PNG)

a riskiness score is computed according to file specifications. if some PNG is RGBA with lot of colors or realistic rendering, it could choose a solution to keep a good compromise between the filesize reduction and quality (the lossy filtering transformation)

original file: lemon.png (253.76 KB): automatic compression (lossy filtering)
original pingo
lemon - original lemon - automatic image compression
253.76 KB 135.38 KB (0.38s) - PNG

few colors or simple structure

it could conversely choose a more effective conversion regarding the filesize if the image has few colors or more simple structure; in this case, it could try to transform the image for paletted encoding

original file: pajarito.png (56.29 KB): automatic compression (paletted)
original pingo
pajarito - original pajarito - automatic image compression
56.29 KB 26.14 KB (0.18s) - PNG

RGB

if the image is RGB or does not require transparency (alpha channel/values), it could be converted to JPG instead of applying something lossy on PNG. this should offer a far better quality/size ratio

original file: fruits-iccp-noalpha.png (385.09 KB): automatic compression (JPG conversion)
original pingo
fruits - sRGB PhotoShop fruits - sRGB pingo auto
385.09 KB 65.29 KB (0.12s) - JPG
PNG JPG

set targeted quality

pingo could set the quality automatically regarding the image specifications. however, you could set a value to target a specific factor to adjust the quality/size ratio yourself

N: from 1 to 100 — 1: smaller filesize, worse quality — 100: bigger filesize, better quality
pingo -auto=N target
original file: peach.png (193.31 KB): automatic compression (lossy filtering)
original pingo -auto=10
peach - original peach - automatic image compression quality 10
193.31 KB 55.34 KB (0.24s) - PNG

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 -auto -sN target