Quantcast
Channel: BuddyPress实验室
Viewing all articles
Browse latest Browse all 34

使用optipng和jpegoptim压缩网站图片

$
0
0

在做GoldPoster这个网站的时候,最头痛的就是图片的处理了,后来安装了optipng和jpegoptim来压缩图片:

sudo apt-get install optipng jpegoptim

执行查找和压缩命令:

find . -iname ‘*.png’ -print0 | xargs -0 optipng -o7 -preserve

find . -iname ‘*.jpg’ -print0 | xargs -0 jpegoptim –max=90 –strip-all –preserve –totals –all-progressive

optipng和jpegoptim都是无损压缩的,另外jpegoptim也提供了有损压缩的选项,在上面的命令中,–max=90这个选项表示图片质量为原图的90%。这样虽然图片质量有所下降,但压缩率会更高,而且用户感觉不出图片的质量下降。


Viewing all articles
Browse latest Browse all 34

Trending Articles