@leeguangxing/img-min-cli

1.0.4 • Public • Published

img-min-cli

Image batch optimization cli tool that supports WebP, PNG and JPEG.

https://leeguangxing.cn/pic/img-min-cli.gif


Usage

  1. Install packages globally:
yarn global add @leeguangxing/img-min-cli

or

npm i -g @leeguangxing/img-min-cli
  1. Execute optimization commands:
img min [options] [dir]

All options

options description
-l, --logger Whether to output the log to the img-min-cli.log file in the execution directory, the optional value is on or off.

Dir

dir is the directory or image file path to be optimized.


Solution

tinypng

API key is required, and the monthly free limit is 500 per email account. For details, see: https://tinypng.com/developers

The cli tool will query the usage of the current month based on the API key and compare it with the number of images that need to be optimized. If the quota cannot complete the task, it will automatically exit.


ENV

You can save your API key in environment TINYPNG_API_KEY. The cli tool will get it from process.env.TINYPNG_API_KEY. Otherwise you need to manually enter it each time.


Example

  1. Compress a single file:
img min test.png
  1. Recursively compress all WebP, PNG, and JPEG images in the entire directory, and output the log to a file (for tracking failed images):
img min your_relative_dir -l on

Package Sidebar

Install

npm i @leeguangxing/img-min-cli

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

10.1 kB

Total Files

8

Last publish

Collaborators

  • leeguangxing