1.0.1 • Published 4 years ago

zsg-tinypng v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

图片压缩工具

使用了 tinypng 的开放接口,地址:https://tinypng.com/

使用

  1. 全局安装
$ npm i zsg-tinypng -g
$ tinypng -i ./[压缩文件夹,使用相对路径] -s[保存图片的EXIF信息]
  1. 本地安装
$ npm i zsg-tinypng -D

在 package.json 的 scripts 中加入

"scripts": {
  "tinypng": "tinypng -i ./"
}
$ npm run tinypng
  1. https://tinify.com/dashboard/api 上获取 key,免费版一个月有500次压缩次数。

  2. 自定义配置文件 打开 node_modules/zsg-tinypng/tinypng.json

{
  "key": "",  // 秘钥
  "count": 494,  // 本月剩余可用
  "ignore": [  // 配置忽略文件夹
    "node_modules",
    "dist",
    "tinypng",
    ".git",
    ".idea",
    ".vscode"
  ],
  "files": [  // 压缩过的图片的md5,避免重复压缩,节省时间。
    "4bda68c4da1a2dbb7a4a33edd44628b5"
  ]
}
1.0.1

4 years ago

1.0.0

4 years ago