papandreou / node-pngquant

The pngquant utility as a readable/writable stream
BSD 3-Clause "New" or "Revised" License
82 stars 23 forks source link

参数中的256是什么意思? #52

Closed SFight closed 2 years ago

papandreou commented 4 years ago

最终将其作为ncolors参数传递给pngquant二进制文件 :)

$ pngquant --help
pngquant, 2.10.1 (July 2017), by Kornel Lesinski, Greg Roelofs.
   Compiled with no support for color profiles. Using libpng 1.6.34.

usage:  pngquant [options] [ncolors] -- pngfile [pngfile ...]
        pngquant [options] [ncolors] - >stdout <stdin

options:
  --force           overwrite existing output files (synonym: -f)
  --skip-if-larger  only save converted files if they're smaller than original
  --output file     destination file path to use instead of --ext (synonym: -o)
  --ext new.png     set custom suffix/extension for output filenames
  --quality min-max don't save below min, use fewer colors below max (0-100)
  --speed N         speed/quality trade-off. 1=slow, 3=default, 11=fast & rough
  --nofs            disable Floyd-Steinberg dithering
  --posterize N     output lower-precision color (e.g. for ARGB4444 output)
  --strip           remove optional metadata (default on Mac)
  --verbose         print status messages (synonym: -v)

Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette.
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).
If you pass the special output path "-" and a single input file, that file
will be processed and the quantized image will go to stdout.
The default behavior if the output file exists is to skip the conversion;
use --force to overwrite. See man page for full list of options.
plas007 commented 2 years ago

请问 ncolors → 192ncolors → 256 有啥区别呢?256是2的8次方,也就是 8-bit 的png,这个示例中的192我确实不太理解

papandreou commented 2 years ago

8-bit PNGs use an indexed pallette with up to 256 entries. You can trim the file size further by using fewer colors.

8 位 PNG 使用最多 256 个条目的索引调色板。 您可以通过使用更少的颜色来进一步修剪文件大小。