介绍
pngquant是一个命令行工具和一个用于有损压缩PNG图像的库。转换显着减少文件大小(通常高达70%),并保留完整的alpha透明度。生成的图像与所有网络浏览器和操作系统兼容。
GitHub源码:https://github.com/kornelski/pngquant
下载
forWindows:https://pngquant.org/pngquant-windows.zip
forMac:https://pngquant.org/pngquant.tar.bz2
安装使用
Windows和mac下都是无需安装的,可以直接使用。
mac: 终端下进入到下载的文件夹,在当前目录行执行./pngquant [参数] file
即可。
Windows: 进入下载的文件夹,可以看到两个后缀为.bat
脚本,文件名就是它的功能。直接拖拽需要压缩的图片到该文件上,即可自行压缩。
参数
See pngquant -h
for full list.
pngquant -h
查看完整的选项列表
--quality min-max
min
and max
are numbers in range 0 (worst) to 100 (perfect), similar to JPEG. pngquant will use the least amount of colors required to meet or exceed the max
quality. If conversion results in quality below the min
quality the image won’t be saved (if outputting to stdin, 24-bit original will be output) and pngquant will exit with status code 99.
min和max是范围从0(最差)到100(完美)的数字,类似于JPEG。pngquant将使用最少的颜色来达到或超过最大的质量。如果转换结果的质量低于最低质量,图像将不会被保存(如果输出到stdin,将输出24位的原始图像),pngquant退出并返回状态码99。
pngquant --quality=65-80 image.png
--ext new.png
Set custom extension (suffix) for output filename. By default -or8.png
or -fs8.png
is used. If you use --ext=.png --force
options pngquant will overwrite input files in place (use with caution).
pngquant --ext=_new.png image.png
pngquant --ext=.pn