如何对 Linux (Mint/Ubuntu) 中的目录进行 PNGCrush?

How to PNGCrush on directories in Linux (Mint/Ubuntu)?

我有一个包含许多图像文件的目录树,然后我必须移动到另一个目录树。但是在这个命运目录中我的png文件必须被压缩。

例如:

源目录树:

./model/layout/img
./model/layout/img/log
./model/layout/img/errs
./model/layout/img/commons

(有很多类型的图像文件)

命运目录树:

./app/img
./app/img/log
./app/img/errs
./app/img/commons

有人对此有解决方案吗?

我在这个站点找到了解决方案。 https://davidwalsh.name/pngcrush-directory.

我只需要稍微修改一下脚本即可。

#!/bin/sh

SRC_DIR=./model/layout/img/
DST_DIR=./app/img/

rm -rf $DST_DIR
cp -R  $SRC_DIR $DST_DIR

for png in `find $DST_DIR -name "*.png"`;
do
    echo "crushing $png"    
    pngcrush -reduce -brute "$png" temp.png

    mv -f temp.png $png
done;