Last Updated: October 12, 2018
·
626
· dflock

Re-compress a folder of PNG files in parallel, using all your cores

You can do this, to process a folder full of PNG files, four at once:

find . -iname "*png" -print0 | xargs -0 --max-procs=4 -n 1 advpng -z -4 -q

This just runs each file through advpng to maximally compress the existing image data, losslessly, without changing the colour depth or quality at all.

You can adjust the --max-procs=4 bit to match the number of cores you have - or maybe one less, if you want to process a lot of images and do other things in the meantime.

There are alternatives to advpng - if you prefer pngout or pngcrush, just replace the advpng -z -4 -q with your preferred compression tool.