cli-anything-gimp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cli-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-gimp
Prerequisites:
  • 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
    draw
    operations are present
该CLI作为cli-anything-gimp包的一部分进行安装:
bash
pip install cli-anything-gimp
前置要求:
  • Python 3.10+
  • 推荐安装gimp以实现原生批量渲染,但当GIMP不可用或存在延迟
    draw
    操作时,仍可通过内置Pillow路径渲染分层合成内容

Usage

使用方法

Basic Commands

基础命令

bash
undefined
bash
undefined

Show 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
undefined
cli-anything-gimp --json project info -p project.json
undefined

REPL Mode

REPL交互模式

When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-gimp
当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-gimp

Enter commands interactively with tab-completion and history

交互式输入命令,支持自动补全和历史记录

undefined
undefined

Command Groups

命令分组

Project

项目管理

Project management commands.
CommandDescription
new
Create a new project
open
Open an existing project
save
Save the current project
info
Show project information
profiles
List available canvas profiles
json
Print raw project JSON
项目管理相关命令。
命令描述
new
创建新项目
open
打开已有项目
save
保存当前项目
info
查看项目信息
profiles
列出可用画布配置
json
打印原始项目JSON数据

Layer

图层管理

Layer management commands.
CommandDescription
new
Create a new blank layer
add-from-file
Add a layer from an image file
list
List all layers
remove
Remove a layer by index
duplicate
Duplicate a layer
move
Move a layer to a new position
set
Set a layer property (name, opacity, visible, mode, offset_x, offset_y); negative offsets are accepted naturally
flatten
Flatten all visible layers
merge-down
Merge a layer with the one below it
图层管理相关命令。
命令描述
new
创建新的空白图层
add-from-file
从图像文件添加图层
list
列出所有图层
remove
通过索引删除图层
duplicate
复制图层
move
将图层移动到新位置
set
设置图层属性(名称、透明度、可见性、混合模式、offset_x、offset_y);支持负偏移值
flatten
合并所有可见图层
merge-down
将当前图层与下方图层合并

Canvas

画布操作

Canvas operations.
CommandDescription
info
Show canvas information
resize
Resize the canvas (without scaling content)
scale
Scale the canvas and all content proportionally
crop
Crop the canvas to a rectangle
mode
Set the canvas color mode
dpi
Set the canvas DPI
画布相关操作命令。
命令描述
info
查看画布信息
resize
调整画布大小(不缩放内容)
scale
按比例缩放画布及所有内容
crop
将画布裁剪为矩形
mode
设置画布颜色模式
dpi
设置画布DPI

Filter Group

滤镜管理

Filter management commands.
CommandDescription
list-available
List all available filters
info
Show details about a filter
add
Add a filter to a layer
remove
Remove a filter by index
set
Set a filter parameter
list
List filters on a layer
滤镜管理相关命令。
命令描述
list-available
列出所有可用滤镜
info
查看滤镜详细信息
add
为图层添加滤镜
remove
通过索引删除滤镜
set
设置滤镜参数
list
列出图层上的所有滤镜

Media

媒体文件操作

Media file operations.
CommandDescription
probe
Analyze an image file
list
List media files referenced in the project
check
Check that all referenced media files exist
histogram
Show histogram analysis of an image
媒体文件相关操作命令。
命令描述
probe
分析图像文件
list
列出项目中引用的所有媒体文件
check
检查所有引用的媒体文件是否存在
histogram
查看图像的直方图分析结果

Export Group

导出/渲染

Export/render commands.
CommandDescription
presets
List export presets
preset-info
Show preset details
render
Render the project to an image file; deferred draw ops are applied at render time
导出与渲染相关命令。
命令描述
presets
列出导出预设
preset-info
查看预设详细信息
render
将项目渲染为图像文件;延迟绘制操作会在渲染时生效

Session

会话管理

Session management commands.
CommandDescription
status
Show session status
undo
Undo the last operation
redo
Redo the last undone operation
history
Show undo history
会话管理相关命令。
命令描述
status
查看会话状态
undo
撤销上一步操作
redo
重做上一步撤销的操作
history
查看撤销历史记录

Draw

绘制操作

Drawing operations (applied at render time).
CommandDescription
text
Draw text on a layer (by converting it to a text layer)
rect
Draw a rectangle (stored as drawing operation)
绘制操作(在渲染时生效)。
命令描述
text
在图层上绘制文字(转换为文字图层)
rect
绘制矩形(存储为绘制操作)

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.json

Or with JSON output for programmatic use

或以JSON格式输出供程序调用

cli-anything-gimp --json project new -o myproject.json
undefined
cli-anything-gimp --json project new -o myproject.json
undefined

Interactive REPL Session

交互式REPL会话

Start an interactive session with undo/redo support.
bash
cli-anything-gimp
启动支持撤销/重做功能的交互式会话。
bash
cli-anything-gimp

Enter commands interactively

交互式输入命令

Use 'help' to see available commands

使用'help'查看可用命令

Use 'undo' and 'redo' for history navigation

使用'undo'和'redo'导航历史操作

undefined
undefined

Export 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 --overwrite

Layered 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 --overwrite
Notes:
  • layer set
    now accepts negative
    offset_x
    and
    offset_y
    values in both command mode and REPL mode.
  • draw text
    and
    draw rect
    are render-time operations. Treat the exported image, not only the project JSON, as the thing to review.
  • 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
注意事项:
  • layer set
    现在在命令模式和REPL模式下均接受负的
    offset_x
    offset_y
    值。
  • draw text
    draw rect
    是渲染时生效的操作。请以导出的图像而非仅项目JSON作为最终审核对象。
  • 对于包含延迟绘制操作的项目,即使已安装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 (
    --json
    flag): Structured JSON for agent consumption
bash
undefined
所有命令支持两种输出模式:
  • 人类可读格式(默认):表格、彩色文本、格式化内容
  • 机器可读格式
    --json
    参数):结构化JSON,供Agent调用
bash
undefined

Human 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
undefined
cli-anything-gimp --json project info -p project.json
undefined

For AI Agents

面向AI Agent的使用指南

When using this CLI programmatically:
  1. Always use
    --json
    flag
    for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
  4. Use absolute paths for all file operations
  5. Verify outputs exist after export operations
  6. Review rendered outputs after offset, draw, blend-mode, or filter changes instead of trusting saved project state alone
以编程方式使用该CLI时:
  1. 始终使用
    --json
    参数
    以获取可解析的输出
  2. 检查返回码——0表示成功,非0表示错误
  3. 解析stderr以获取失败时的错误信息
  4. 使用绝对路径执行所有文件操作
  5. 导出操作后验证输出文件是否存在
  6. 在调整偏移、绘制、混合模式或滤镜后,查看渲染输出结果,而非仅依赖保存的项目状态

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