lubanpng 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # lubanpng
2
+
3
+ LubanPNG 命令行图片压缩:把 PNG、JPEG、GIF、WebP、AVIF 刨薄,不伤画质。整个目录,一条命令。
4
+
5
+ 与网页、API 共用同一账号的一份额度:未登录每天 5 次,注册后每月 50 次;只有真正产出更小文件才计一次,失败与没变小都不计。
6
+
7
+ 在线使用与 API 文档:https://lubanpng.wizthink.cn
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ npm i -g lubanpng
13
+ ```
14
+
15
+ Node 24+,macOS / Linux / Windows。
16
+
17
+ ## 使用
18
+
19
+ ```bash
20
+ lubanpng login # 粘贴 API Key,校验后保存到本机
21
+ lubanpng logout # 清除本机保存的 Key
22
+ lubanpng compress ./images --out ./dist # 压缩文件或目录
23
+ lubanpng compress ./images --recursive --in-place # 递归并覆盖原文件
24
+ lubanpng compress ./hero.png --convert webp # 转换格式(额外计 1 次)
25
+ lubanpng usage # 查看套餐、本期用量与重置时间
26
+ ```
27
+
28
+ `compress` 选项:
29
+
30
+ - `--out <dir>`:输出目录,保持输入目录结构
31
+ - `--in-place`:覆盖原文件
32
+ - `--recursive`:递归处理目录
33
+ - `--concurrency <n>`:并发数,默认 4,最大 16
34
+ - `--convert <fmt>`:转换输出格式,可选 `png`、`jpeg`、`webp`、`avif`(额外计 1 次)
35
+ - `--background <hex>`:透明图转 JPEG 时的背景色,如 `#ffffff`
36
+
37
+ Key 存在本机用户配置目录(macOS / Linux 为 `~/.config/lubanpng`,Windows 为 `%APPDATA%\lubanpng`),也可用环境变量 `LUBANPNG_API_KEY`;API 地址可用 `--api-base` 或 `LUBANPNG_API_BASE` 覆盖。
38
+
39
+ HEIC:macOS 上用系统转换器先转成 JPEG 再上传;其他平台与 `--in-place` 会报明确错误,请先自行导出 JPEG。
40
+
41
+ ## 开发
42
+
43
+ ```bash
44
+ pnpm install
45
+ pnpm --filter lubanpng build
46
+ pnpm --filter lubanpng test
47
+ ```
48
+
49
+ ## License
50
+
51
+ MIT
@@ -162,7 +162,7 @@ export const compressCommand = async (context, options) => {
162
162
  }
163
163
  const compressed = pair.compressed.padStart(SIZE_COLUMN);
164
164
  if (outcome.retained) {
165
- context.io.write(` ${name} ${original} → ${compressed} 无收益,保留原图\n`);
165
+ context.io.write(` ${name} ${original} → ${compressed} 无收益,保留原图(不计次)\n`);
166
166
  return;
167
167
  }
168
168
  const percent = savingsPercent(outcome.originalSize, outcome.compressedSize);
@@ -242,7 +242,7 @@ export const compressCommand = async (context, options) => {
242
242
  if (converted.length > 0)
243
243
  parts.push(`${converted.length} 张已转换`);
244
244
  if (retained.length > 0)
245
- parts.push(`${retained.length} 张无收益保留原图`);
245
+ parts.push(`${retained.length} 张无收益保留原图(不计次)`);
246
246
  if (failed.length > 0)
247
247
  parts.push(`${failed.length} 张失败`);
248
248
  context.io.write(` ${parts.join(",")}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lubanpng",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "LubanPNG command line image compressor",
5
5
  "type": "module",
6
6
  "bin": {