cli-anything-gimp
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecli-anything-gimp
cli-anything-gimp
A stateful command-line interface for image editing, built on Pillow. Designed for AI agents and power users who need to create and manipulate images without a GUI.
一个基于Pillow构建的有状态图像编辑命令行工具,专为AI Agent和无需GUI即可创建及处理图像的高级用户设计。
Installation
安装
This CLI is installed as part of the cli-anything-gimp package:
bash
pip install cli-anything-gimpPrerequisites:
- Python 3.10+
- gimp is recommended for native batch rendering, but layered compositions can
still render through the built-in Pillow path when GIMP is unavailable or when
deferred operations are present
draw
该CLI作为cli-anything-gimp包的一部分进行安装:
bash
pip install cli-anything-gimp前置要求:
- Python 3.10+
- 推荐安装gimp以实现原生批量渲染,但当GIMP不可用或存在延迟操作时,仍可通过内置Pillow路径渲染分层合成内容
draw
Usage
使用方法
Basic Commands
基础命令
bash
undefinedbash
undefinedShow help
查看帮助
cli-anything-gimp --help
cli-anything-gimp --help
Start interactive REPL mode
启动交互式REPL模式
cli-anything-gimp
cli-anything-gimp
Create a new project
创建新项目
cli-anything-gimp project new -o project.json
cli-anything-gimp project new -o project.json
Run with JSON output (for agent consumption)
以JSON格式输出(供Agent调用)
cli-anything-gimp --json project info -p project.json
undefinedcli-anything-gimp --json project info -p project.json
undefinedREPL Mode
REPL交互模式
When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-gimp当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-gimpEnter commands interactively with tab-completion and history
交互式输入命令,支持自动补全和历史记录
undefinedundefinedCommand Groups
命令分组
Project
项目管理
Project management commands.
| Command | Description |
|---|---|
| Create a new project |
| Open an existing project |
| Save the current project |
| Show project information |
| List available canvas profiles |
| Print raw project JSON |
项目管理相关命令。
| 命令 | 描述 |
|---|---|
| 创建新项目 |
| 打开已有项目 |
| 保存当前项目 |
| 查看项目信息 |
| 列出可用画布配置 |
| 打印原始项目JSON数据 |
Layer
图层管理
Layer management commands.
| Command | Description |
|---|---|
| Create a new blank layer |
| Add a layer from an image file |
| List all layers |
| Remove a layer by index |
| Duplicate a layer |
| Move a layer to a new position |
| Set a layer property (name, opacity, visible, mode, offset_x, offset_y); negative offsets are accepted naturally |
| Flatten all visible layers |
| Merge a layer with the one below it |
图层管理相关命令。
| 命令 | 描述 |
|---|---|
| 创建新的空白图层 |
| 从图像文件添加图层 |
| 列出所有图层 |
| 通过索引删除图层 |
| 复制图层 |
| 将图层移动到新位置 |
| 设置图层属性(名称、透明度、可见性、混合模式、offset_x、offset_y);支持负偏移值 |
| 合并所有可见图层 |
| 将当前图层与下方图层合并 |
Canvas
画布操作
Canvas operations.
| Command | Description |
|---|---|
| Show canvas information |
| Resize the canvas (without scaling content) |
| Scale the canvas and all content proportionally |
| Crop the canvas to a rectangle |
| Set the canvas color mode |
| Set the canvas DPI |
画布相关操作命令。
| 命令 | 描述 |
|---|---|
| 查看画布信息 |
| 调整画布大小(不缩放内容) |
| 按比例缩放画布及所有内容 |
| 将画布裁剪为矩形 |
| 设置画布颜色模式 |
| 设置画布DPI |
Filter Group
滤镜管理
Filter management commands.
| Command | Description |
|---|---|
| List all available filters |
| Show details about a filter |
| Add a filter to a layer |
| Remove a filter by index |
| Set a filter parameter |
| List filters on a layer |
滤镜管理相关命令。
| 命令 | 描述 |
|---|---|
| 列出所有可用滤镜 |
| 查看滤镜详细信息 |
| 为图层添加滤镜 |
| 通过索引删除滤镜 |
| 设置滤镜参数 |
| 列出图层上的所有滤镜 |
Media
媒体文件操作
Media file operations.
| Command | Description |
|---|---|
| Analyze an image file |
| List media files referenced in the project |
| Check that all referenced media files exist |
| Show histogram analysis of an image |
媒体文件相关操作命令。
| 命令 | 描述 |
|---|---|
| 分析图像文件 |
| 列出项目中引用的所有媒体文件 |
| 检查所有引用的媒体文件是否存在 |
| 查看图像的直方图分析结果 |
Export Group
导出/渲染
Export/render commands.
| Command | Description |
|---|---|
| List export presets |
| Show preset details |
| Render the project to an image file; deferred draw ops are applied at render time |
导出与渲染相关命令。
| 命令 | 描述 |
|---|---|
| 列出导出预设 |
| 查看预设详细信息 |
| 将项目渲染为图像文件;延迟绘制操作会在渲染时生效 |
Session
会话管理
Session management commands.
| Command | Description |
|---|---|
| Show session status |
| Undo the last operation |
| Redo the last undone operation |
| Show undo history |
会话管理相关命令。
| 命令 | 描述 |
|---|---|
| 查看会话状态 |
| 撤销上一步操作 |
| 重做上一步撤销的操作 |
| 查看撤销历史记录 |
Draw
绘制操作
Drawing operations (applied at render time).
| Command | Description |
|---|---|
| Draw text on a layer (by converting it to a text layer) |
| Draw a rectangle (stored as drawing operation) |
绘制操作(在渲染时生效)。
| 命令 | 描述 |
|---|---|
| 在图层上绘制文字(转换为文字图层) |
| 绘制矩形(存储为绘制操作) |
Examples
使用示例
Create a New Project
创建新项目
Create a new gimp project file.
bash
cli-anything-gimp project new -o myproject.json创建新的gimp项目文件。
bash
cli-anything-gimp project new -o myproject.jsonOr with JSON output for programmatic use
或以JSON格式输出供程序调用
cli-anything-gimp --json project new -o myproject.json
undefinedcli-anything-gimp --json project new -o myproject.json
undefinedInteractive REPL Session
交互式REPL会话
Start an interactive session with undo/redo support.
bash
cli-anything-gimp启动支持撤销/重做功能的交互式会话。
bash
cli-anything-gimpEnter commands interactively
交互式输入命令
Use 'help' to see available commands
使用'help'查看可用命令
Use 'undo' and 'redo' for history navigation
使用'undo'和'redo'导航历史操作
undefinedundefinedExport Project
导出项目
Export the project to a final output format.
bash
cli-anything-gimp --project myproject.json export render output.png --overwrite将项目导出为最终输出格式。
bash
cli-anything-gimp --project myproject.json export render output.png --overwriteLayered Composition Workflow
分层合成工作流
For overlay-heavy compositions:
bash
cli-anything-gimp --project poster.gimp-cli.json layer set 0 offset_x -48
cli-anything-gimp --project poster.gimp-cli.json layer set 0 offset_y 24
cli-anything-gimp --project poster.gimp-cli.json draw text --layer 0 --text "Launch Night" --x 96 --y 120 --size 72 --color "#f6f1e8"
cli-anything-gimp --project poster.gimp-cli.json export render output.png --overwriteNotes:
- now accepts negative
layer setandoffset_xvalues in both command mode and REPL mode.offset_y - and
draw textare render-time operations. Treat the exported image, not only the project JSON, as the thing to review.draw rect - For projects with deferred draw ops, expect the Pillow render path to be the stable default even if GIMP is installed.
针对叠加密集的合成场景:
bash
cli-anything-gimp --project poster.gimp-cli.json layer set 0 offset_x -48
cli-anything-gimp --project poster.gimp-cli.json layer set 0 offset_y 24
cli-anything-gimp --project poster.gimp-cli.json draw text --layer 0 --text "Launch Night" --x 96 --y 120 --size 72 --color "#f6f1e8"
cli-anything-gimp --project poster.gimp-cli.json export render output.png --overwrite注意事项:
- 现在在命令模式和REPL模式下均接受负的
layer set和offset_x值。offset_y - 和
draw text是渲染时生效的操作。请以导出的图像而非仅项目JSON作为最终审核对象。draw rect - 对于包含延迟绘制操作的项目,即使已安装GIMP,Pillow渲染路径仍会作为稳定默认选项。
State Management
状态管理
The CLI maintains session state with:
- Undo/Redo: Up to 50 levels of history
- Project persistence: Save/load project state as JSON
- Session tracking: Track modifications and changes
该CLI通过以下方式维护会话状态:
- 撤销/重做:最多支持50级历史记录
- 项目持久化:以JSON格式保存/加载项目状态
- 会话跟踪:跟踪修改和变更记录
Output Formats
输出格式
All commands support dual output modes:
- Human-readable (default): Tables, colors, formatted text
- Machine-readable (flag): Structured JSON for agent consumption
--json
bash
undefined所有命令支持两种输出模式:
- 人类可读格式(默认):表格、彩色文本、格式化内容
- 机器可读格式(参数):结构化JSON,供Agent调用
--json
bash
undefinedHuman output
人类可读输出
cli-anything-gimp project info -p project.json
cli-anything-gimp project info -p project.json
JSON output for agents
供Agent使用的JSON输出
cli-anything-gimp --json project info -p project.json
undefinedcli-anything-gimp --json project info -p project.json
undefinedFor AI Agents
面向AI Agent的使用指南
When using this CLI programmatically:
- Always use flag for parseable output
--json - Check return codes - 0 for success, non-zero for errors
- Parse stderr for error messages on failure
- Use absolute paths for all file operations
- Verify outputs exist after export operations
- Review rendered outputs after offset, draw, blend-mode, or filter changes instead of trusting saved project state alone
以编程方式使用该CLI时:
- 始终使用参数以获取可解析的输出
--json - 检查返回码——0表示成功,非0表示错误
- 解析stderr以获取失败时的错误信息
- 使用绝对路径执行所有文件操作
- 导出操作后验证输出文件是否存在
- 在调整偏移、绘制、混合模式或滤镜后,查看渲染输出结果,而非仅依赖保存的项目状态
More Information
更多信息
- Full documentation: See README.md in the package
- Test coverage: See TEST.md in the package
- Methodology: See HARNESS.md in the cli-anything-plugin
- 完整文档:查看包中的README.md
- 测试覆盖率:查看包中的TEST.md
- 实现方法:查看cli-anything-plugin中的HARNESS.md
Version
版本
1.0.0
1.0.0