tinypng-cli

安装

npm install -g tinypng-cli

获取token

# 通过页面生成
https://tinypng.com/developers

# 得到
6wKvJqrYHWwqTvR94yJvRZmNWzvyQqGd

将token放入~/.tinypng 文件下

echo 6wKvJqrYHWwqTvR94yJvRZmNWzvyQqGd > ~/.tingpng

使用

tinypng . -r -k 6wKvJqrYHWwqTvR94yJvRZmNWzvyQqGd

原理

TinyPNG uses smart lossy compression techniques to reduce the file size of your WEBP, JPEG and PNG files. By selectively decreasing the number of colors in the image, fewer bytes are required to store the data. The effect is nearly invisible but it makes a very large difference in file size!

why should I use TinyPNG

PNG is useful because it’s the only widely supported format that can store partially transparent images. The format uses compression, but the files can still be large. Use TinyPNG to shrink images for your apps and sites. It will use less bandwidth and load faster.