A CLI to compress your images not only intelligently but also to the EXTREME!
Compress using tinify which is used by TinyPNG and TinyJPG. Read more at http://tinify.com.
npx tinify-client IMG_URL_OR_LOCAL_IMG_PATH
用 tinypng.com 使用的压缩技术将图片压缩到极致。
解决需要手动将一张图片拖放到 tinypng 十几次才能达到极致压缩的难题
# 压缩单张或多张本地图片或来自 CDN 的图片
npx tinify-client IMG_URL_OR_LOCAL_IMG_PATH_1 [IMG_URL_OR_LOCAL_IMG_PATH_2 [IMG_URL_OR_LOCAL_IMG_PATH_3]]
# 压缩指定目录下的图片
npx tinify-client DIRECTORY
# 图片转 base64
npx tinify-client base64 IMG_URL_OR_LOCAL_IMG_PATH
如果没有开始压缩,请设置 Key。
Key 可从 https://tinypng.com/developers 免费获取,获取过程很简单不要有心理负担。一行命令设置:
tinify set-key YOUR_TINIFY_KEY
参数介绍,详细介绍 tinify -h
:
- key: tinypng 需要的 key
- src: 支持 cdn 地址或本地图片
- output -o: 最终压缩图片的地址
- max-count -m: 最大压缩次数,默认 15 次
- version: 显示该工具的版本号
- verbose: 显示每一次压缩的日志
- no-base64: 不显示压缩图片的 base64。默认显示
- Compress not only intelligently but also to the EXTREME!
- Compress images in a batch.
- Image to base64.
For more usage try npx tinify-client -h
.
-
compress and output the compressed image's base64
npx tinify-client IMG_URL_OR_LOCAL_IMG_PATH_1 [IMG_URL_OR_LOCAL_IMG_PATH_2 [IMG_URL_OR_LOCAL_IMG_PATH_3]]
-
compress all the pngs and jpgs in a folder
npx tinify-client DIRECTORY
-
image to base64 only (No need to configure the key)
npx tinify-client base64 IMG_URL_OR_LOCAL_IMG_PATH
-
Get your key at https://tinypng.com/developers.
-
$ tinify set-key YOUR_TINIFY_KEY
More parameters tinify -h
:
- output -o: The compressed img file path.
- max-count -m: Set the max compressing turns. Default 15.
- version: Show the version.
- verbose: Show more information about each compressing turn.
- no-base64: Not output the base64 of the compressed image. base64 encoded by default.
LANG=zh-CN node src/cli https://tinypng.com/images/panda-happy.png max-count=1
CLI Powered by cli-aid. ❤️
- 压缩文件夹下面所有的 png jpg
- cli 参数支持多张图片
- 压缩单张图片默认打开输出的目录