SVGZ and lossy compression

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

pingo could do lossy compression using a combination of non-scalable SVG container and JPG which should be supported, even on some old browsers. this lossy transformation could be more effective on RGBA samples which have lot of colors or complex structure

-svgz=N

N: from 1 to 100 — 1: smaller filesize, worse quality — 100: bigger filesize, better quality
pingo -svgz=N target
original file: lab.png (300.14 KB): svgz container and lossy compression
original pingo -svgz=100 pingo -svgz=98
lab - original lab - svgz lossy 100 lab - svgz lossy 98
300.14 KB 148.19 KB (0.19s) 108.31 KB (0.13s)
dssim - butteraugli 0.00008343 - 1.334959 0.00011533 - 1.437129
pingo -svgz=96 pingo -svgz=94 pingo -svgz=92
lab - svgz lossy 96 lab - svgz lossy 94 lab - svgz lossy 92
83.03 KB (0.12s) 72.84 KB (0.14s) 63.78 KB (0.13s)
0.00016909 - 1.781699 0.00020546 - 1.933385 0.00025776 - 2.255524
pingo -svgz=90 pingo -svgz=85 pingo -svgz=80
lab - svgz lossy 90 lab - svgz lossy 85 lab - svgz lossy 80
57.34 KB (0.12s) 47.86 KB (0.11s) 40.90 KB (0.11s)
0.00031958 - 3.018729 0.00044659 - 3.482207 0.00061863 - 3.608042
pingo -svgz=75 pingo -svgz=70 pingo -svgz=65
lab - svgz lossy 75 lab - svgz lossy 70 lab - svgz lossy 65
36.93 KB (0.10s) 32.91 KB (0.10s) 29.99 KB (0.13s)
0.00074609 - 3.830279 0.00095816 - 4.015732 0.00112195 - 4.487676

infos

  • image data should be automatically converted to sRGB colour space if required
  • this should be compatible even on some legacy browsers (IE9, FireFox/Chrome 31, Safari 5.1, Opera 24, Android 4.4)
  • -nocompression should create svg files instead of svgz. svg files can be read directly by browsers
svgz options
flags range effect default
-svgz=N 25 to 100 less quality, more savings -svgz
-svgz-auto=N 25 to 100 average quality, average savings -svgz-auto
-svgz-hq=N 25 to 100 more quality, less savings -svgz-hq

use svgz

svgz files can be read by some editors like Inkscape. for web, you could need to add some instructions to serve svgz files accordingly

example on htaccess file
AddEncoding gzip .svgz
AddType image/svg+xml .svgz

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

related notes