image optimizer for web

pingo a fast image optimizer for web

pingo is an experimental lossless and lossy image optimizer (PNG, JPEG, WebP, APNG) designed to be used for web context — it does image reductions over iterations by performing its own heuristics to target the image content. since most of features are not fully implemented, it would be recommended to do backup or use only on test files

pingo optimizing 400 files pingo — optimizing 400 PNG files losslessly for web

usage (examples)

pingo [options] files/folders
pingo -s0 *.png
pingo -s0 myfolder
pingo -s0 c:\myfolder

PNG — lossless

pingo -sN file.png
N from 0 to 9, optimization level

the lossless PNG optimizer in pingo does heuristic ordered transforms to make the data more compressible losslessly for web. it performs an highly optimized deflation according to the user-level. see also the PNG lossless benchmark-sa or -sb do more trials

pingo -s9 — palette optimization
infile outfile time
43,09 KB 24,69 KB 0,55s
pingo -sb — alpha and predictors
infile outfile time
59,71 KB 50,69 KB 0,51s
pingo -s9 — ordered transform
infile outfile time
607,27 KB 38,75 KB 0,45s

JPEG — lossless

pingo -sN file.jpg
N from 0 to 9, automatic lossless

the JPEG lossless optimizer in pingo is just like mozjpeg with some automatic transform on image data — rotation according to the orientation flag. instead of using the automatic lossless profile, user could add jpgtype=N to force the encoding

pingo -s0 -jpgtype=N
infile outfile time
1435,45 KB 0: 1365,87 KB 0,08s
1: 1323,17 KB 0,15s
2: 1275,36 KB 0,47s

WebP — lossless

the WebP lossless optimizer uses a tweaked libwebp — it could try its own heuristics to determine transformations. this implementation is incomplete at this moment: it makes sense to try it on paletted samples where it uses a different way to sort colors

pingo -s9 — WebP as input
infile outfile time
130,44 KB 99,70 KB 0,52s
pingo -webp-lossless -s9 — PNG as input
infile outfile time
126,09 KB 99,70 KB 0,50s

APNG — lossless

the APNG optimizer would try to re-create the animation by using some transformations. this implementation is incomplete at this moment: it could not be able to select an optimal colortype or bitdepth

pingo -s9 — palette optimization
infile outfile time
114,19 KB 103,26 KB 0,97s
pingo -s0 — alpha + predictors
infile outfile time
621,74 KB 527,09 KB 0,49s

PNG — lossy

pingo would let the user to try several lossy transformations for PNG. it makes sense to use those transformations from high quality source — not to apply those several times on the same file

-auto or -auto=N

N = 1 to 100 as quality factor: 1 = very low, 100 = best effort. this would attempt to optimize the file automatically, by picking the lossy transformation (eventually lossless) by itself. this implementation is incomplete at this moment: it uses only fast heuristics which could be wrong

pingo -auto — lossy predictors
infile outfile time
300,62 KB 77,42 KB 0,30s
pingo -auto=1 — lossy predictors
infile outfile time
300,62 KB 52,61 KB 0,20s
pingo -auto — lossy palettization
infile outfile time
83,10 KB 26,61 KB 0,13s
pingo -auto — lossless
infile outfile time
171,02 KB 21,66 KB 0,12s

-pngfilter or -pngfilter=N

N = 1 to 100 as quality factor: 1 = low, 100 = near-lossless. this would try to transform image data using predictors. would be efficient on image with lot of colors / noise, and less efficient on low colored images

pingo -pngfilter — lossy predictors
infile outfile time
947,55 KB 405,88 KB 0,91s

-pngpalette or -pngpalette=N

N = 1 to 100 as quality factor: 1 = very low, 100 = best effort. this would try to transform image data by palettization. would be efficient on low colored images, and could have limitations for high colored ones

pingo -pngpalette — lossy palettization
infile outfile time
189,75 KB 8,66 KB 0,11s

-pngcolor or -pngcolor=N

N = 1 to 100 as quality factor: 1 = low, 100 = near-lossless. this would try to reduce image data using color transformation. this usually get the closest near-lossless result if used with highest value, but could do less savings; could be useful on moderately colored images

pingo -pngfilter — lossy color transform
infile outfile time
102,93 KB 63,64 KB 0,14s

JPEG — lossy

the JPEG lossy uses sjpeg — it does 4:4:4 by default, with automatic settings according to the sample. eventually, user could set the following flag:

-jpgquality=N

N = 1 to 100 as quality factor: 1 = low, 100 = best effort. without any other flag, it should not try to do subsampling, unless source is already 4:2:0 JPEG

pingo -jpgquality=N — JPEG quantization
infile outfile time
1499,08 KB 95: 572,02 KB 0,23s
75: 216,64 KB 0,15s

-jpgsub

this would enable the JPEG subsampling but by using a sharp filter on high quality source. this attempt could offer a better rendering than regular subsampling

pingo -jpgquality=N -jpgsub — JPEG quantization with sharp_yuv
infile outfile time
1499,08 KB 95: 438,02 KB 0,32s
75: 174,72 KB 0,21s

WebP — lossy/auto

the WebP lossy optimizer in pingo uses sharp_yuv by default on high quality source. it could give different results from the reference encoder — e.g. image pre-processing on PNG with alpha, automatic compression, etc.

-webp-lossy or -webp-lossy=N

N = 1 to 100 as quality factor: 1 = low, 100 = best effort

pingo -webp-lossy=N — WebP lossy with alpha pre-processing
infile outfile time
227,86 KB 100: 40,53 KB 0,07s
  84: 20,08 KB 0,06s

-webp or -webp=N

N = 1 to 100 as quality factor: 1 = low, 100 = best effort. just like -auto, it would pick a transform according to the image data, including a lossless one if it seems more suitable. this implementation is incomplete at this moment: it uses only fast heuristics which could be wrong

pingo -webp — WebP automatic lossy compression
infile outfile time
634,71 KB 13,00 KB 0,08s
pingo -webp — WebP automatic lossless compression
infile outfile time
171,02 KB 7,07 KB 0,13s
pingo -webp -s9 — WebP automatic lossless compression
infile outfile time
43,09 KB 24,24 KB 0,32s

-webp-palette or -webp-palette=N

N = 1 to 100 as quality factor: 1 = low, 100 = best effort. just like -pngpalette, this would try to transform image data by palettization

pingo -webp-palette=100 — WebP palettization
infile outfile time
18,91 KB 10,78 KB 0,09s

WebP — near-lossless

if -webp-lossy has some limitations (YUV420) regarding quality, one could try a near-lossless transform instead. pingo includes several way to do this according to the sample

-webp-near or -webp-near=N

N = 1 to 100 as quality factor: 1 = low, 100 = best quality. this is a slighlty tweaked version from the one in libwebp

pingo -webp-near=100 — WebP near-lossless
infile outfile time
231,19 KB 112,74 KB 0,27s

-webp-color or -webp-color=N

N = 1 to 100 as quality factor: 1 = low, 100 = best quality. use color transformation: it should be faster than -webp-near but could be less efficient on various image type. provide different quality/size ratio — not always better

pingo -webp-color=100 — WebP near-lossless, by color transform
infile outfile time
231,19 KB 107,51 KB 0,18s

-webp-filter or -webp-filter=N

N = 1 to 100 as quality factor: 1 = low, 100 = best quality. use predictors to transform data: only efficient on image with lot of colors, probably less efficient than -webp-color

pingo -webp-color=100 — WebP near-lossless, by color transform
infile outfile time
231,19 KB 108,23 KB 0,20s

-webp-nigh or -webp-nigh=N

just like -auto, but would pick a near-lossless transform automatically according to the sample. this implementation is incomplete at this moment: it uses only fast heuristics which could be wrong

image transformations

-strip

even without using -strip, pingo would remove most of non-critical chunks/segments from PNG/JPG except some, as colors profile, which could be useful or affect rendering. -strip would be more strict, and should leave only critical data

-srgb

convert image data to sRGB by perceptual intent from the color profile. enabled by default on all lossy transformations whatever the format — could be disabled by using -nosrgb. once converted, the color profile would be removed from the optimized file. this would also convert CMYK JPG

PNG
pingo -s0 — no transformation, use ICC colors profile
infile outfile time
218,46 KB 154,20 KB 0,25s
pingo -s0 -strip — no transformation, strip the ICC colors profile
infile outfile time
218,46 KB 153,87 KB 0,29s
pingo -s0 -srgb — do transform *without* additional loss, strip the ICC colors profile
infile outfile time
218,46 KB 110,67 KB 0,31s
pingo -auto — do transform *with* additional loss, strip the ICC colors profile
infile outfile time
218,46 KB 76,09 KB 0,24s
JPEG
pingo -jpgconvert — do transform *with* additional loss, strip the ICC colors profile
infile outfile time
218,46 KB 19,00 KB 0,05s
pingo -auto — CMYK to sRGB
infile outfile time
714,17 KB 60,03 KB 0,09s
WebP
pingo -webp — do transform *with* additional loss, strip the ICC colors profile
infile outfile time
218,46 KB 37,13 KB 0,10s

-enhance or -enhance=N

N = 1 to 8 as factor: 1 = low, 8 = high sharpness. increase image details in some area while transforming image data to make it more compressible. this implementation is incomplete at this moment: it uses only fast heuristics

pingo -enhance -s0 — enhance details and compression
infile outfile time
435,40 KB 330,73 KB 0,09s
pingo -enhance — enhance details and compression
infile outfile time
435,40 KB 248,46 KB 0,13s

-grayscale

convert image data to grey level. used with -sN in non-automatic mode, it should try to convert image with no loss over the transform. used in automatic mode, it would try to apply loss over the grey level conversion

PNG
pingo -grayscale -s0 — convert to grayscale *without* additional loss
infile outfile time
171,02 KB 146,40 KB 0,15s
pingo -grayscale — convert to grayscale *with* additional loss
infile outfile time
171,02 KB 102,71 KB 0,16s
JPEG
pingo -grayscale -s0 — convert to grayscale *without* additional loss
infile outfile time
147,27 KB 62,05 KB 0,03s
pingo -grayscale — convert to grayscale *with* additional loss
infile outfile time
147,27 KB 11,48 KB 0,05s
WebP
pingo -grayscale -s0 — convert to grayscale *without* additional loss
infile outfile time
171,02 KB 114,16 KB 0,15s
pingo -grayscale — convert to grayscale *with* additional loss
infile outfile time
171,02 KB 95,16 KB 0,19s
APNG
pingo -grayscale — convert to grayscale *with* additional loss
infile outfile time
84,60 KB 47,01 KB 0,28s

-notrans

transform image data to make it non-transparent by colors blending. in automatic mode, this could convert PNG to JPG (could be disabled by adding -sN). user could set -notrans=N N N, where N is R, G, and B color value from 0 to 255 (default is 255,255,255 (white))

pingo -notrans -s0 — color blending, *without* additional loss
infile outfile time
761,38 KB 351,90 KB 0,14s
pingo -notrans — color blending, conversion from PNG to JPEG
infile outfile time
761,38 KB 52,71 KB 0,09s

-svgz or -svgz=N

N = 1 to 100 as quality factor: 1 = low, 100 = near-lossless. convert PNG images with lot of colors to compressed SVG container — this have to be served accordingly, but could be used in most of browsers (~2011). could be useful where recent codecs are not supported. -nocompression creates SVG files instead of SVGZ

pingo -svgz=97 — PNG to SVGZ
infile outfile time
761,38 KB 238,02 KB 0,17s
pingo -svgz=97 -nocompression — PNG to SVG
infile outfile time
761,38 KB 325,60 KB 0,09s

manual updated on 19 July 2021