automatic image compression (WebP)

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

pingo could convert PNG to WebP, using automatic and alternative lossy transforms. the -webp flag should do the same routine as -auto to determine what to perform, but output should be WebP format

pingo -webp target

RGBA, simple structure

a riskiness score is computed according to file specifications. for image with simple structure like the following one, pingo should pick a paletted transformation, which could offer both better quality and/or smaller filesize

original file: surfer.png (18.38 KB): automatic compression (WebP conversion)
cwebp (default) pingo (default)
surfer - cwebp default surfer - pingo default
9.20 KB 7.78 KB
0.00100665 0.00000591
2.686121 1.401044

lossless in auto

in some cases, pingo could pick an alternative WebP lossless encoding instead of always trying to apply lossy on input image data. it could happen on some samples, like paletted PNG

original file: sprite-google.png (10.14 KB): automatic compression (WebP conversion)
cwebp (default) pingo (default)
sprite google - cwebp default sprite google - pingo default
15.26 KB 9.95 KB
0.00175414 lossless
6.816216 lossless

less aggressive lossy

the default WebP lossy in pingo is less agressive than default WebP lib (e.g. cwebp tool) but could produce larger filesize

original file: flower-red.png (81.77 KB): automatic compression (WebP conversion)
cwebp (default) pingo (default)
red flower - cwebp default red flower - pingo default
13.11 KB 23.63 KB
0.00553659 0.00161475
6.720984 2.805714

lossy conversion to sRGB

if lossy process is applied and if the file could need to be converted to sRGB, the conversion should be done automatically to the sRGB colourspace

original file: flowers.png (83.45 KB): automatic compression (WebP and automatic sRGB conversion)
cwebp (default) cwebp (-metadata icc) pingo (default)
flowers - cwebp default flowers - cwebp default + icc flowers - pingo default
13.76 KB 14.31 KB 25.53 KB
no ICC data ICC data no ICC data (image converted to sRGB)

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 -webp=N target
original file: peach.png (193.31 KB): set WebP quality
original pingo -webp=75
peach - original peach - automatic image compression quality 10
193.31 KB 15.82 KB (0.17s)

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