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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pz4l/tinyimg-cli

v0.0.4

Published

[![npm](https://img.shields.io/npm/v/@pz4l/tinyimg-cli)](https://www.npmjs.com/package/@pz4l/tinyimg-cli)

Downloads

52

Readme

@pz4l/tinyimg-cli

npm

TinyPNG 图片压缩 CLI。

安装

npm i -g @pz4l/tinyimg-cli

或通过 npx 免安装使用:

npx @pz4l/tinyimg-cli src/assets/**

用法

全局选项

| 选项 | 别名 | 说明 | 默认值 | | --------------------------- | ---- | ------------------- | ------- | | -o, --output <dir> | — | 输出目录 | — | | -s, --strategy <strategy> | — | 压缩策略 | AUTO | | --no-cache | — | 禁用缓存 | false | | -k, --key <keys> | — | 逗号分隔的 API 密钥 | — | | -p, --parallel <number> | — | 并行限制 | 3 |

命令

默认命令(压缩)

tinyimg src/assets/**
tinyimg src/assets/** -o dist/images
tinyimg src/assets/** -s API_FIRST -k YOUR_API_KEY

tinyimg convert <paths>

将无透明通道的 PNG 转换为 JPG。

  • --noRename — 保留原始 .png 扩展名(仅更改编码)

示例:

tinyimg convert src/assets/**
tinyimg convert src/assets/** --noRename

tinyimg keys <subcommand>

管理 API 密钥。

  • tinyimg keys add <key> — 添加并验证 API 密钥(支持同时添加多个)
  • tinyimg keys del <maskedKey> — 删除已保存的密钥
  • tinyimg keys(无子命令)— 列出所有密钥

示例:

tinyimg keys add your_api_key
tinyimg keys add key1 key2 key3
tinyimg keys del xxxx...xxxx
tinyimg keys

tinyimg list <paths>(别名 ls

列出图片文件及其元数据。

  • --json — 以 JSON 格式输出
  • --convert-c — 仅显示可转换的 PNG

示例:

tinyimg list src/assets/**
tinyimg ls src/assets/** -c

压缩策略

  • API_ONLY:始终使用 TinyPNG API。需要提供 API key。
  • RANDOM:随机在 API 和 Web 端点之间选择。
  • API_FIRST:优先使用 API;当 API key 无效或触发限流时回退到 Web 端点。
  • AUTO:有 API key 时等同于 API_FIRST,否则等同于 RANDOM

API 密钥设置

项目级密钥

CLI 启动时自动读取当前工作目录下的 .env.env.local

支持的变量名:TINYIMG_KEYTINYIMG_KEYSTINYPNG_KEYTINYPNG_KEYS(以及任何带前缀的变体,如 VITE_TINYIMG_KEY — 按后缀匹配)。

.env.local 示例:

TINYIMG_KEY=your_api_key

用户级密钥

通过 tinyimg keys add <key> 存储在 ~/.tinyimg/keys.json 中。当没有项目级密钥时作为回退使用。

许可证

MIT