0

我正在尝试使用具有以下结构的 pngquant 处理文件夹目录:

C:\ ├───FOLDER │ ├───0 │ │ └───0 │ ├───1 │ │ └───0 │ └───2 │ ├───113 │ ├───114 │ ├───120 │ └───121

我正在使用 pngquant 来降低C:\folder\1\0\*.png. 我这样做 *.png 因为每个文件夹可能包含 300 多个小 PNG 文件,但我需要遍历所有文件夹并使用压缩的 PNG 在另一个位置复制确切的文件夹结构。

在 Windows 中,我有一个 shell 脚本

for d in $(find C:/$folder_name -maxdepth 2 -type d)
do
    path/to/pngquant.exe --ext .png --force 2 $d/*.png
done

但这只会覆盖目录中的所有文件。

这是pngquant的帮助手册。

pngquant, 2.0.0 (March 2013), by Greg Roelofs, Kornel Lesinski. Compiled with libpng 1.5.14; using libpng 1.5.14. usage: pngquant [options] [ncolors] [pngfile [pngfile ...]] options: --force overwrite existing output files (synonym: -f) --nofs disable Floyd-Steinberg dithering --ext new.png set custom suffix/extension for output filename --speed N speed/quality trade-off. 1=slow, 3=default, 11=fast & rough --quality min-max don't save below min, use less colors below max (0-100) --verbose print status messages (synonym: -v) --iebug increase opacity to work around Internet Explorer 6 bug --transbug transparent color will be placed at the end of the palette Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette PNGs using Floyd-Steinberg diffusion dithering (unless disabled). The output filename is the same as the input name except that it ends in "-fs8.png", "-or8.png" or your custom extension (unless the input is stdin, in which case the quantized image will go to stdout). The default behavior if the output file exists is to skip the conversion; use --force to overwrite.

4

0 回答 0