tinyit

压缩图片

Usage no npm install needed!

<script type="module">
  import tinyit from 'https://cdn.skypack.dev/tinyit';
</script>

README

Compress picture 压缩图片

Command line version tinypng.com, say goodbye to the limit of up to 20 images, max 5 MB each.

To a specified directory, compress all pictures in the directory, and then output to the given directory. No image compression, directly copy to the output directory -filter parameter

命令行版的 tinypng.com, 告别 Up to 20 images, max 5 MB each 的限制。

给一个指定目录,压缩该目录下的所有图片,然后输出到给定的目录。非图片不压缩,直接复制到输出目录 -filter 参数


# install
npm instal tinyit

# compress, npx tinyit [source dir] [target dir]
npx tinyit ./teams ./dist
# 过滤非图片输出
npx tinyit ./teams ./dist -filter

# 如果出现 key 不正确,请自己申请 key https://tinypng.com/developers
npx tinyit ./teams ./dist -key=YOUR_API_KEY

Picture type can only be pngjpgjpeg

图片类型只能是 pngjpgjpeg

The compression algorithm is tinypng

压缩算法是 tinypng

option

  • -key

tinypng key,默认我申请的,如果出现错误,需要自己申请

  • -filter

是否输出非压缩的文件,默认会是,如果不想复制非图片文件,请添加参数 -filter=true 或者 -filter