@playcraft/cli 0.0.39 → 0.0.41

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.
Files changed (121) hide show
  1. package/README.md +66 -3
  2. package/dist/atom-plan/validate-atom-plan.js +298 -0
  3. package/dist/cli-root-help.js +1 -1
  4. package/dist/commands/3d.js +363 -0
  5. package/dist/commands/create.js +337 -0
  6. package/dist/commands/fix-ids.js +17 -3
  7. package/dist/commands/fix-ids.test.js +264 -0
  8. package/dist/commands/image.js +1337 -43
  9. package/dist/commands/login.js +60 -2
  10. package/dist/commands/recommend.js +1 -1
  11. package/dist/commands/remix.js +213 -0
  12. package/dist/commands/skills.js +1379 -0
  13. package/dist/commands/tools-3d.js +473 -0
  14. package/dist/commands/tools-generation.js +454 -0
  15. package/dist/commands/tools-project.js +400 -0
  16. package/dist/commands/tools-research.js +37 -0
  17. package/dist/commands/tools-research.test.js +216 -0
  18. package/dist/commands/tools-utils.js +164 -0
  19. package/dist/commands/tools.js +7 -616
  20. package/dist/config.js +2 -0
  21. package/dist/index.js +20 -2
  22. package/dist/utils/agent-api-client.js +52 -16
  23. package/package.json +9 -3
  24. package/project-template/.claude/agents/designer.md +116 -0
  25. package/project-template/.claude/agents/developer.md +133 -0
  26. package/project-template/.claude/agents/pm.md +164 -0
  27. package/project-template/.claude/agents/refs/README.md +67 -0
  28. package/project-template/.claude/agents/refs/designer-art-style-catalog.md +533 -0
  29. package/project-template/.claude/agents/refs/designer-color-audio-recipes.md +153 -0
  30. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +167 -0
  31. package/project-template/.claude/agents/refs/designer-dimension-axis.md +27 -0
  32. package/project-template/.claude/agents/refs/designer-handoff-v2-checklist.md +68 -0
  33. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +216 -0
  34. package/project-template/.claude/agents/refs/designer-style-exploration-flow.md +37 -0
  35. package/project-template/.claude/agents/refs/developer-dev-handoff.md +109 -0
  36. package/project-template/.claude/agents/refs/developer-impl-cookbook.md +134 -0
  37. package/project-template/.claude/agents/refs/developer-phase1-flow.md +211 -0
  38. package/project-template/.claude/agents/refs/pm-workflow-detail.md +545 -0
  39. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +286 -0
  40. package/project-template/.claude/agents/refs/ta-3d-flip-recipe.md +85 -0
  41. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +46 -0
  42. package/project-template/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  43. package/project-template/.claude/agents/refs/ta-image-generation-detail.md +356 -0
  44. package/project-template/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  45. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +699 -0
  46. package/project-template/.claude/agents/refs/ta-tools-reference.md +111 -0
  47. package/project-template/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  48. package/project-template/.claude/agents/reviewer.md +103 -0
  49. package/project-template/.claude/agents/technical-artist.md +111 -0
  50. package/project-template/.claude/hooks/README.md +36 -0
  51. package/project-template/.claude/hooks/validate-atom-plan.mjs +224 -0
  52. package/project-template/.claude/hooks/validate-workflow-stop.mjs +258 -0
  53. package/project-template/.claude/settings.json +32 -0
  54. package/project-template/.claude/settings.local.json +4 -0
  55. package/project-template/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  56. package/project-template/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  57. package/project-template/.claude/skills/playcraft-asset-state-sheet/SKILL.md +141 -0
  58. package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  59. package/project-template/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  60. package/project-template/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  61. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +229 -0
  62. package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  63. package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  64. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +235 -0
  65. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  66. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  67. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  68. package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  69. package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  70. package/project-template/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  71. package/project-template/.claude/skills/playcraft-masking/SKILL.md +373 -0
  72. package/project-template/.claude/skills/playcraft-research/SKILL.md +212 -0
  73. package/project-template/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  74. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +148 -0
  75. package/project-template/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  76. package/project-template/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  77. package/project-template/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  78. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +396 -0
  79. package/project-template/.cursor/hooks.json +17 -0
  80. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +87 -0
  81. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +18 -0
  82. package/project-template/CLAUDE.md +240 -0
  83. package/project-template/assets/audio/bgm/.gitkeep +0 -0
  84. package/project-template/assets/audio/sfx/.gitkeep +0 -0
  85. package/project-template/assets/bundles/.gitkeep +0 -0
  86. package/project-template/assets/images/bg/.gitkeep +0 -0
  87. package/project-template/assets/images/reference/.gitkeep +0 -0
  88. package/project-template/assets/images/storyboard/.gitkeep +0 -0
  89. package/project-template/assets/images/tiles/.gitkeep +0 -0
  90. package/project-template/assets/images/ui/.gitkeep +0 -0
  91. package/project-template/assets/images/vfx/.gitkeep +0 -0
  92. package/project-template/assets/models/.gitkeep +0 -0
  93. package/project-template/docs/team/agent-conduct.md +105 -0
  94. package/project-template/docs/team/agent-runtime-matrix.md +62 -0
  95. package/project-template/docs/team/atom-plan-format.md +74 -0
  96. package/project-template/docs/team/collaboration.md +288 -0
  97. package/project-template/docs/team/core-model.md +50 -0
  98. package/project-template/docs/team/platform-capabilities.md +15 -0
  99. package/project-template/docs/team/workflow-changelog.md +51 -0
  100. package/project-template/docs/team/workflow-consistency-checklist.md +128 -0
  101. package/project-template/game/config/.gitkeep +0 -0
  102. package/project-template/game/gameplay/.gitkeep +0 -0
  103. package/project-template/game/scenes/.gitkeep +0 -0
  104. package/project-template/logs/.gitkeep +0 -0
  105. package/project-template/ta-workspace/logs/.gitkeep +0 -0
  106. package/project-template/ta-workspace/scripts/.gitkeep +0 -0
  107. package/project-template/ta-workspace/tmp/.gitkeep +0 -0
  108. package/project-template/templates/atom-plan.template.json +26 -0
  109. package/project-template/templates/atom-plan.template.md +76 -0
  110. package/project-template/templates/design-brief.template.md +195 -0
  111. package/project-template/templates/design-lens-checklist.reference.md +117 -0
  112. package/project-template/templates/design-methodology.md +99 -0
  113. package/project-template/templates/designer-log.template.md +98 -0
  114. package/project-template/templates/developer-log.template.md +140 -0
  115. package/project-template/templates/five-axis-framework.md +186 -0
  116. package/project-template/templates/intent-clarifications.template.md +58 -0
  117. package/project-template/templates/layout-spec.template.md +132 -0
  118. package/project-template/templates/project-state.template.md +219 -0
  119. package/project-template/templates/review-report.template.md +166 -0
  120. package/project-template/templates/style-exploration.template.md +93 -0
  121. package/project-template/templates/ta-log.template.md +205 -0
@@ -0,0 +1,495 @@
1
+ > 本文件是 `playcraft image` 子命令的完整 CLI 参数速查表。生产上下文指南见 `playcraft-image-ops` skill。
2
+
3
+ # PlayCraft 图形操作完整指南
4
+
5
+ ## 0. 命令总览
6
+
7
+ 所有命令均为 `playcraft image <子命令>` 格式,基于 sharp 本地处理,无需后端。
8
+
9
+ | 命令 | 核心用途 |
10
+ | ----------- | ----------------------------- |
11
+ | `crop` | 精确裁切矩形区域 |
12
+ | `overlay` | 底图 + 叠加图合成 |
13
+ | `pad` | 扩展画布(加边距) |
14
+ | `trim` | 自动裁掉透明/纯色边缘 |
15
+ | `resize` | 缩放 |
16
+ | `rotate` | 旋转 |
17
+ | `flip` | 水平/垂直翻转 |
18
+ | `blur` | 高斯模糊 |
19
+ | `tint` | 色调叠加 |
20
+ | `grayscale` | 灰度化 |
21
+ | `negate` | 反色 |
22
+ | `convert` | 格式转换(PNG/WebP/AVIF/JPG) |
23
+ | `info` | 查看尺寸/格式/文件大小 |
24
+
25
+ ---
26
+
27
+ ## 1. crop — 精确裁切
28
+
29
+ ### 基础用法
30
+
31
+ ```bash
32
+ playcraft image crop \
33
+ --input assets/images/source.png \
34
+ --output assets/images/cropped.png \
35
+ --x 100 \ # 左边缘(像素,从左上角起)
36
+ --y 200 \ # 上边缘(像素)
37
+ --width 512 \ # 裁切宽度
38
+ --height 512 # 裁切高度
39
+ ```
40
+
41
+ **参数说明**:`x` + `y` 是左上角起点坐标,`width` + `height` 是裁切区域大小。所有参数为像素整数。
42
+
43
+ ### 常用裁切模式
44
+
45
+ #### 居中裁(最常用)
46
+
47
+ 从图片中心裁取目标尺寸:
48
+
49
+ ```bash
50
+ # 从 1080×1920 图居中裁取 512×512
51
+ # x = (1080 - 512) / 2 = 284
52
+ # y = (1920 - 512) / 2 = 704
53
+ playcraft image crop \
54
+ --input assets/images/bg/background.png \
55
+ --output assets/images/tiles/center_crop.png \
56
+ --x 284 --y 704 --width 512 --height 512
57
+ ```
58
+
59
+ **居中裁公式**:
60
+
61
+ - `x = (原图宽 - 目标宽) / 2`(取整)
62
+ - `y = (原图高 - 目标高) / 2`(取整)
63
+
64
+ #### 顶部裁(保留上半部分)
65
+
66
+ ```bash
67
+ # 裁取图片顶部 1/3 区域
68
+ playcraft image crop \
69
+ --input source.png \
70
+ --output top_crop.png \
71
+ --x 0 --y 0 --width 1080 --height 640
72
+ ```
73
+
74
+ #### 提取局部区域(制作素材变体)
75
+
76
+ ```bash
77
+ # 从精灵图提取单个帧(已知帧位置时用 crop,不规则布局用 sprite-split)
78
+ playcraft image crop \
79
+ --input assets/images/tiles/tile_sheet.png \
80
+ --output assets/images/tiles/tile_001.png \
81
+ --x 0 --y 0 --width 128 --height 128
82
+
83
+ # 提取第 2 帧(横向排列,每帧 128px)
84
+ playcraft image crop \
85
+ --input assets/images/tiles/tile_sheet.png \
86
+ --output assets/images/tiles/tile_002.png \
87
+ --x 128 --y 0 --width 128 --height 128
88
+ ```
89
+
90
+ ### crop vs sprite-split 选型
91
+
92
+ | 场景 | 推荐 |
93
+ | -------------------------- | --------------------------------------------- |
94
+ | 精确知道帧位置(均匀网格) | `crop` 或 `sprite-split --rows N --columns N` |
95
+ | 不规则布局 / 不知道帧位置 | `sprite-split --auto-detect` |
96
+ | 只提取图片的一个局部区域 | `crop` |
97
+
98
+ > **注意**:`crop` 不支持在 `playcraft image batch --steps` 中使用(已知 CLI 限制,运行时报 `unsupported command "crop"`)。批量裁切请用 Node.js 脚本或 for 循环。
99
+
100
+ ---
101
+
102
+ ## 2. overlay — 合成叠图
103
+
104
+ 将一张图叠加在另一张图上。用于:添加阴影/光晕、叠加徽章/标签、合成多个素材层。
105
+
106
+ ### 基础用法
107
+
108
+ ```bash
109
+ playcraft image overlay \
110
+ --base assets/images/bg/background.png \ # 底图(决定输出尺寸)
111
+ --overlay assets/images/ui/badge.png \ # 叠加图
112
+ --output assets/images/composite.png
113
+ ```
114
+
115
+ 输出尺寸 = 底图尺寸(与叠加图大小无关)。
116
+
117
+ ### Gravity 模式(对齐位置)
118
+
119
+ 不指定 `--x`/`--y` 时,用 `--gravity` 控制叠加图的对齐位置:
120
+
121
+ | gravity 值 | 对齐位置 |
122
+ | ---------------- | -------- |
123
+ | `center`(默认) | 居中 |
124
+ | `north` | 顶部居中 |
125
+ | `south` | 底部居中 |
126
+ | `east` | 右侧居中 |
127
+ | `west` | 左侧居中 |
128
+ | `northeast` | 右上角 |
129
+ | `northwest` | 左上角 |
130
+ | `southeast` | 右下角 |
131
+ | `southwest` | 左下角 |
132
+
133
+ ```bash
134
+ # 将徽章放在右上角
135
+ playcraft image overlay \
136
+ --base assets/images/tiles/tile_001.png \
137
+ --overlay assets/images/ui/new_badge.png \
138
+ --output assets/images/tiles/tile_001_badge.png \
139
+ --gravity northeast
140
+
141
+ # 将 CTA 按钮放在底部居中
142
+ playcraft image overlay \
143
+ --base assets/images/bg/endcard_bg.png \
144
+ --overlay assets/images/ui/cta_button.png \
145
+ --output assets/images/endcard_composite.png \
146
+ --gravity south
147
+ ```
148
+
149
+ ### 精确定位(--x + --y)
150
+
151
+ **同时提供** `--x` 和 `--y` 时,叠加图左上角放置在底图的 `(x, y)` 坐标处(忽略 gravity):
152
+
153
+ ```bash
154
+ # 精确放置:叠加图左上角在底图 (200, 150) 处
155
+ playcraft image overlay \
156
+ --base assets/images/bg/background.png \
157
+ --overlay assets/images/ui/icon.png \
158
+ --output assets/images/composite.png \
159
+ --x 200 \
160
+ --y 150
161
+ ```
162
+
163
+ ### 典型场景配方
164
+
165
+ #### 添加阴影(先生成阴影层再叠加)
166
+
167
+ ```bash
168
+ # 1. 用 tint 把原图变成纯黑色版本作为阴影
169
+ playcraft image tint \
170
+ --input assets/images/character.png \
171
+ --output /tmp/shadow.png \
172
+ --color "#000000"
173
+
174
+ # 2. 把阴影叠加到背景,位置偏移 +4px
175
+ playcraft image overlay \
176
+ --base assets/images/bg/background.png \
177
+ --overlay /tmp/shadow.png \
178
+ --output /tmp/bg_with_shadow.png \
179
+ --x 4 --y 4
180
+
181
+ # 3. 再把原图叠到正确位置(居中)
182
+ playcraft image overlay \
183
+ --base /tmp/bg_with_shadow.png \
184
+ --overlay assets/images/character.png \
185
+ --output assets/images/final_composite.png \
186
+ --gravity center
187
+ ```
188
+
189
+ #### 给素材添加光晕边框
190
+
191
+ ```bash
192
+ # 先 pad 扩大原图作为光晕层(用半透明背景),再叠回原图
193
+ playcraft image pad \
194
+ --input assets/images/tiles/tile_001.png \
195
+ --output /tmp/glow_layer.png \
196
+ --all 8 \
197
+ --background "#FFD70088" # 半透明金色
198
+
199
+ playcraft image overlay \
200
+ --base /tmp/glow_layer.png \
201
+ --overlay assets/images/tiles/tile_001.png \
202
+ --output assets/images/tiles/tile_001_glow.png \
203
+ --gravity center
204
+ ```
205
+
206
+ ---
207
+
208
+ ## 3. pad — 扩展画布
209
+
210
+ 在图片四周添加边距,常用于:统一精灵图尺寸、添加安全边距、适配不同宽高比。
211
+
212
+ ### 基础用法
213
+
214
+ ```bash
215
+ # 四边均等扩展 16px(透明填充)
216
+ playcraft image pad \
217
+ --input assets/images/tiles/tile_001.png \
218
+ --output assets/images/tiles/tile_001_padded.png \
219
+ --all 16
220
+
221
+ # 四边分别指定
222
+ playcraft image pad \
223
+ --input assets/images/ui/button.png \
224
+ --output assets/images/ui/button_safe.png \
225
+ --top 24 \
226
+ --bottom 24 \
227
+ --left 32 \
228
+ --right 32 \
229
+ --background "#00000000" # 透明(默认)
230
+ ```
231
+
232
+ ### 典型场景
233
+
234
+ #### 统一精灵图尺寸(大小不一的图片变成相同画布)
235
+
236
+ ```bash
237
+ # 将 96×112 的角色精灵扩展到 128×128(居中内容)
238
+ # top = (128-112)/2 = 8, bottom = 8, left = (128-96)/2 = 16, right = 16
239
+ playcraft image pad \
240
+ --input assets/images/character_sprite.png \
241
+ --output assets/images/character_128x128.png \
242
+ --top 8 --bottom 8 --left 16 --right 16
243
+ ```
244
+
245
+ #### 添加安全边距(防止 UI 元素贴边)
246
+
247
+ ```bash
248
+ playcraft image pad \
249
+ --input assets/images/ui/cta_button.png \
250
+ --output assets/images/ui/cta_button_safe.png \
251
+ --all 48 \
252
+ --background "#00000000"
253
+ ```
254
+
255
+ #### 白色/彩色填充背景(不透明)
256
+
257
+ ```bash
258
+ playcraft image pad \
259
+ --input assets/images/icon.png \
260
+ --output assets/images/icon_white_bg.png \
261
+ --all 20 \
262
+ --background "#FFFFFF"
263
+ ```
264
+
265
+ ---
266
+
267
+ ## 4. trim — 自动裁掉边缘
268
+
269
+ 自动检测并移除图片边缘的透明区域或纯色边缘。常用于:精灵图去白边、AI 生成图去冗余透明边。
270
+
271
+ ```bash
272
+ # 移除透明边缘(默认阈值 10)
273
+ playcraft image trim \
274
+ --input assets/images/tiles/tile_001.png \
275
+ --output assets/images/tiles/tile_001_trimmed.png
276
+
277
+ # 调整阈值(0-255,越高容错越大)
278
+ # 阈值 30:稍微偏白的背景也会被裁掉
279
+ playcraft image trim \
280
+ --input assets/images/ui/icon.png \
281
+ --output assets/images/ui/icon_trimmed.png \
282
+ --threshold 30
283
+ ```
284
+
285
+ **什么时候用 trim**:
286
+
287
+ - AI 生成的图片四周有半透明区域
288
+ - 精灵图合并前需要统一去掉白色/透明边距
289
+ - `remove-background` 处理后的图片有冗余透明像素
290
+
291
+ **trim 后通常接 pad**:先 trim 去掉不需要的边,再 pad 统一添加所需的安全边距。
292
+
293
+ ---
294
+
295
+ ## 5. rotate / flip — 旋转与翻转
296
+
297
+ ```bash
298
+ # 旋转 90 度(顺时针),填充透明
299
+ playcraft image rotate \
300
+ --input assets/images/arrow.png \
301
+ --output assets/images/arrow_rotated.png \
302
+ --angle 90
303
+
304
+ # 旋转并指定填充色
305
+ playcraft image rotate \
306
+ --input assets/images/bg/background.png \
307
+ --output assets/images/bg/background_rotated.png \
308
+ --angle 15 \
309
+ --background "#1A1A2E"
310
+
311
+ # 水平翻转(左右镜像)
312
+ playcraft image flip \
313
+ --input assets/images/character/run_right.png \
314
+ --output assets/images/character/run_left.png \
315
+ --direction horizontal
316
+
317
+ # 垂直翻转(上下镜像)
318
+ playcraft image flip \
319
+ --input assets/images/tiles/water.png \
320
+ --output assets/images/tiles/water_flipped.png \
321
+ --direction vertical
322
+ ```
323
+
324
+ **典型用途**:
325
+
326
+ - `rotate 90/180/270`:调整素材方向
327
+ - `flip horizontal`:从"向右跑"生成"向左跑",节省一半动画生成成本
328
+ - `rotate 15` + 透明背景:制作倾斜装饰元素
329
+
330
+ ---
331
+
332
+ ## 6. 滤镜命令(blur / tint / grayscale / negate)
333
+
334
+ ### blur — 高斯模糊
335
+
336
+ ```bash
337
+ # sigma 越大,模糊程度越高(默认 3)
338
+ playcraft image blur \
339
+ --input assets/images/bg/background.png \
340
+ --output assets/images/bg/background_blurred.png \
341
+ --sigma 8
342
+
343
+ # 背景虚化(大 sigma)
344
+ playcraft image blur --input bg.png --output bg_bokeh.png --sigma 15
345
+ ```
346
+
347
+ **典型用途**:背景虚化强调前景角色;制作毛玻璃效果底图;对参考图模糊处理减少 AI 参考图的细节影响。
348
+
349
+ ### tint — 色调叠加
350
+
351
+ ```bash
352
+ # 整体染色(不影响透明通道)
353
+ playcraft image tint \
354
+ --input assets/images/tiles/tile_001.png \
355
+ --output assets/images/tiles/tile_001_gold.png \
356
+ --color "#FFD700"
357
+
358
+ # 制作禁用状态(灰色叠加)
359
+ playcraft image tint \
360
+ --input assets/images/ui/button.png \
361
+ --output assets/images/ui/button_disabled.png \
362
+ --color "#808080"
363
+ ```
364
+
365
+ **注意**:tint 是颜色混合,不是替换颜色。深色图像 tint 效果不明显,用 `overlay` + 纯色图层效果更可控。
366
+
367
+ ### grayscale — 灰度化
368
+
369
+ ```bash
370
+ playcraft image grayscale \
371
+ --input assets/images/tiles/tile_001.png \
372
+ --output assets/images/tiles/tile_001_gray.png
373
+ ```
374
+
375
+ **典型用途**:制作"锁定/未解锁"状态的灰色版本素材;从彩色图快速生成黑白版本作为蒙版参考。
376
+
377
+ ### negate — 反色
378
+
379
+ ```bash
380
+ playcraft image negate \
381
+ --input assets/images/ui/icon.png \
382
+ --output assets/images/ui/icon_inverted.png
383
+
384
+ # 仅反色 RGB,保留透明通道
385
+ playcraft image negate \
386
+ --input assets/images/ui/icon.png \
387
+ --output assets/images/ui/icon_inverted.png \
388
+ --no-alpha
389
+ ```
390
+
391
+ ---
392
+
393
+ ## 7. convert — 格式转换
394
+
395
+ ```bash
396
+ # 转换为 WebP(有损,质量 85)
397
+ playcraft image convert \
398
+ --input assets/images/bg/background.png \
399
+ --output assets/images/bg/background.webp \
400
+ --format webp \
401
+ --quality 85
402
+
403
+ # 转换为 WebP 无损(适合像素艺术和 UI)
404
+ playcraft image convert \
405
+ --input assets/images/ui/icon.png \
406
+ --output assets/images/ui/icon.webp \
407
+ --format webp \
408
+ --lossless
409
+
410
+ # 转换为 AVIF(更小体积,兼容性稍差)
411
+ playcraft image convert \
412
+ --input assets/images/bg/background.png \
413
+ --output assets/images/bg/background.avif \
414
+ --format avif \
415
+ --quality 80
416
+ ```
417
+
418
+ **格式选型建议**(生产阶段):
419
+
420
+ - 生产阶段统一用 **PNG**(无损,最大兼容性,方便后续处理)
421
+ - 格式转换交给构建阶段的 `playcraft build --convert-webp` 批量处理
422
+
423
+ ---
424
+
425
+ ## 8. info — 查看图片信息
426
+
427
+ ```bash
428
+ # 查看尺寸、格式、文件大小
429
+ playcraft image info --input assets/images/bg/background.png
430
+
431
+ # JSON 格式输出(方便脚本解析)
432
+ playcraft image info --input assets/images/bg/background.png --json
433
+ ```
434
+
435
+ 输出包含:`width`、`height`、`format`、`channels`、`size`(字节)、`hasAlpha`。
436
+
437
+ ---
438
+
439
+ ## 9. 完整参数速查表
440
+
441
+ | 命令 | 必填参数 | 可选参数 | 默认值 |
442
+ | ----------- | -------------------------------------------------------- | -------------------------------------------------- | -------------- |
443
+ | `crop` | `--input --output --x --y --width --height` | — | — |
444
+ | `overlay` | `--base --overlay --output` | `--x --y --gravity` | gravity=center |
445
+ | `pad` | `--input --output` | `--top --bottom --left --right --all --background` | 0px / 透明 |
446
+ | `trim` | `--input --output` | `--threshold` | 10 |
447
+ | `resize` | `--input --output` + (`--width`/`--height` 或 `--scale`) | `--fit` | fit=cover |
448
+ | `rotate` | `--input --output --angle` | `--background` | 透明 |
449
+ | `flip` | `--input --output` | `--direction` | horizontal |
450
+ | `blur` | `--input --output` | `--sigma` | 3 |
451
+ | `tint` | `--input --output --color` | — | — |
452
+ | `grayscale` | `--input --output` | — | — |
453
+ | `negate` | `--input --output` | `--no-alpha` | — |
454
+ | `convert` | `--input --output` | `--format --quality --lossless` | quality=85 |
455
+ | `info` | `--input` | `--json` | — |
456
+
457
+ ---
458
+
459
+ ## 10. 常用组合配方
460
+
461
+ ### 配方 A:统一精灵图尺寸
462
+
463
+ ```bash
464
+ # 1. 裁掉冗余透明边
465
+ playcraft image trim --input raw_sprite.png --output /tmp/trimmed.png
466
+
467
+ # 2. 用 pad 统一到目标尺寸(128×128)
468
+ # (trim 后获取尺寸:playcraft image info --input /tmp/trimmed.png --json)
469
+ playcraft image pad \
470
+ --input /tmp/trimmed.png \
471
+ --output final_sprite_128x128.png \
472
+ --top 8 --bottom 8 --left 16 --right 16
473
+ ```
474
+
475
+ ### 配方 B:制作"选中高亮"效果
476
+
477
+ ```bash
478
+ # 1. 生成发光边框层(pad + tint)
479
+ playcraft image pad --input tile.png --output /tmp/glow.png --all 6 --background "#FFD70099"
480
+ # 2. 把原图叠回
481
+ playcraft image overlay --base /tmp/glow.png --overlay tile.png --output tile_selected.png --gravity center
482
+ ```
483
+
484
+ ### 配方 C:批量生成镜像动画帧
485
+
486
+ ```bash
487
+ # 已有向右跑的动画帧,批量生成向左跑
488
+ for f in assets/images/character/run_right_*.png; do
489
+ name=$(basename "$f" .png)
490
+ playcraft image flip \
491
+ --input "$f" \
492
+ --output "assets/images/character/${name/right/left}.png" \
493
+ --direction horizontal
494
+ done
495
+ ```