npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

inke-tinypng

v1.0.5

Published

`inke-tinypng` 使用了网页版 tinypng 的压缩图片接口 `https://tinypng.com/web/shrink` ,参考借鉴了知乎专栏文章《原来TinyPNG可以这样玩!》原文链接:https://zhuanlan.zhihu.com/p/152317953 ,在该作者的基础上,加入了一些常用配置,并且可以递归遍历文件夹等。

Downloads

20

Readme

inke-tinypng 压缩图片

inke-tinypng 使用了网页版 tinypng 的压缩图片接口 https://tinypng.com/web/shrink ,参考借鉴了知乎专栏文章《原来TinyPNG可以这样玩!》原文链接:https://zhuanlan.zhihu.com/p/152317953 ,在该作者的基础上,加入了一些常用配置,并且可以递归遍历文件夹等。

说明:

  1. 只支持压缩 png | jpg | jpeg 文件
  2. 受限于网页版 tinypng 的接口限制,最大只能压缩 5MB 即 5120KB 的图片
  3. 可设置 basePath 方便频繁输入某个路径下的文件/文件夹的场景
  4. 可设置 minSize ,在执行 dir 压缩文件时,指定大于 minSize 的文件才进行压缩(单张图片压缩时该配置不生效)
  5. 默认配置 config.basePath./src/pagesconfig.minSize10 ,可进行更改

安装:

npm i inke-tinypng -g

使用:

  • img:ikt img <path> [options]

    压缩单张图片,输出路径和原文件同级,默认情况下压缩输出的文件名和原文件一致,即覆盖。当配置了 basePath 时,最终查找的文件路径为 basePath > path 。基本使用:

    ikt img ./public/test.png
    • 选项

      • -r:rretain 的缩写,指定该选项后压缩输出的文件名将会在原文件名的基础上添加后缀 .tiny

        ikt img ./public/test.png -r // ==> test.tiny.png
  • dir:ikt dir <path> [options]

    压缩文件夹里所有满足条件的图片,当配置了 config.basePath 时,最终查找的文件路径为 basePath > path 。基本使用:

    ikt dir ./public
    • -d:ddeep 的缩写,指定该选项后为深度遍历文件夹,获取所有满足条件的图片进行压缩

      ikt dir ./public -d
    • -ms:msminSize 的缩写,设置压缩的最小文件大小,单位KB,设置后只有大于 minSize 的图片才会进行压缩,该指令后跟整数,权重大于 config.minSize

      ikt dir ./public -ms 10
    • -r:rretain 的缩写,指定该选项后压缩输出的文件名将会在原文件名的基础上添加后缀 .tiny

      ikt dir ./public -r
    • -o:ooutput 的缩写,后跟文件名/路径,指定该选项后,图片压缩后会输出到指定的文件夹中

      ikt dir ./public -o output // ==> 最终输出目录 ./public/output
  • config:获取配置信息

  • config.set.basePath:设置基路径,img | dir 压缩时指定的 path 将相对于 baesPathbasePath 值应为一个文件夹路径

    ikt config.set.basePath ./src/pages
  • config.clear.basePath:删除配置的基路径

    ikt config.clear.basePath
  • config.set.minSize:设置最小文件大小,单位KB,需为整数,并且小于5120KB,只有执行dir时,该配置才会生效,config.minSize 权重小于命令行 -ms 选项

  • config.clear.minSize:删除配置的最小文件大小限制