使用pngquant命令近乎无损压缩PNG图片大小减少70%左右

Posted cn三少nginx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用pngquant命令近乎无损压缩PNG图片大小减少70%左右相关的知识,希望对你有一定的参考价值。

1.安装

wget http://pngquant.org/pngquant-2.8.2-src.tar.gz

tar -xzf pngquant-2.8.2-src.tar.gz

cd pngquant-2.8.2

安装依赖:yum install libpng-devel

./configure 

make && make install

ok ,安装完成。 

pngquant -h 看是否正常,如果报:pngquant: error while loading shared libraries: liblcms2.so.2: cannot open shared object file: No such file or directory

重新装一下liblcms2 , yum install http://pkgrepo.linuxtech.net/el6/release/x86_64/liblcms2-2.4-1.el6.x86_64.rpm 解决

Options

See pngquant -h for full list of options.

--ext new.png

Set custom extension for output filename. By default -or8.png or -fs8.png is used.

--quality min-max

Instructs pngquant to 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 stdout, 24-bit original will be output) and pngquant will exit with status code 99.

min and max are numbers in range 0 (worst) to 100 (perfect), similar to JPEG.

 

pngquant --quality=65-80 image.png
--speed N-sN

Speed/quality trade-off from 1 (brute-force) to 10 (fastest). The default is 3. Speed 10 has 5% lower quality, but is 8 times faster than the default.

--iebug

Workaround for IE6, which only displays fully opaque pixels. pngquant will make almost-opaque pixels fully opaque and will avoid creating new transparent colors.

--version

Print version information to stdout.

-

Read image from stdin and send result to stdout.

--

Stops processing of arguments. This allows use of file names that start with -. If you‘re using pngquant in a script, it‘s advisable to put this before file names:

pngquant $OPTIONS -- "$FILE"

以上是关于使用pngquant命令近乎无损压缩PNG图片大小减少70%左右的主要内容,如果未能解决你的问题,请参考以下文章

png图片怎么通过代码实现压缩到指定的文件大小,比如5M压缩到200KB,比如用pngquant或imageMagick

使用pngquant来缩小你的APK

Android使用.webp替换.jpeg与.png格式图片减少图片大小

这样使用Node.js压缩PNG图片,效果高达75%

python 开发一款图片压缩工具:上传图床

java webp图片转换为png或jpg