Recursively batch process files with pngquant

六月ゝ 毕业季﹏ 提交于 2019-11-28 16:52:41

If you have limited depth of directories and not too many files, then lazy solution:

pngquant *.png */*.png */*/*.png

A standard solution:

find . -name '*.png' -exec pngquant --ext .png --force 256 {} \;

and multi-core version:

find . -name '*.png' -print0 | xargs -0 -P8 -L1 pngquant --ext .png --force 256

where -P8 defines number of CPUs, and -L1 defines a number of images to process in one pngquant call (I use -L4 for folders with a lot of small images to save on process start).

With the fish shell you can run the following from the root of your project directory

pngquant **.png

Which will generate new files with extensions like -or8.png or -fs8.png.

If you want to overwrite the existing files, you can use

pngquant **.png --ext .png --force
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!