doc-smith-images

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Doc-Smith 图片生成

Doc-Smith Image Generation

使用 AI 生成图片,支持技术图表、架构图、流程图等。
Generate images using AI, supporting technical diagrams, architecture diagrams, flowcharts, etc.

用法

Usage

bash
undefined
bash
undefined

基础用法:描述要生成的图片

Basic usage: Describe the image to generate

/doc-smith-images "系统架构图,展示微服务之间的调用关系"
/doc-smith-images "System architecture diagram showing the call relationships between microservices"

指定输出路径

Specify output path

/doc-smith-images "用户登录流程图" --savePath ./images/login-flow.png
/doc-smith-images "User login flowchart" --savePath ./images/login-flow.png

指定宽高比

Specify aspect ratio

/doc-smith-images "系统架构图" --ratio 16:9 /doc-smith-images "数据流向图" -r 4:3
/doc-smith-images "System architecture diagram" --ratio 16:9 /doc-smith-images "Data flow diagram" -r 4:3

指定图片尺寸

Specify image size

/doc-smith-images "概念图" --size 4K
/doc-smith-images "Concept map" --size 4K

指定图片中文字的语言

Specify language of text in image

/doc-smith-images "API 调用流程" --locale en
/doc-smith-images "API call flow" --locale en

更新已有图片(基于原图修改)

Update existing image (modify based on original image)

/doc-smith-images "优化配色和布局" --update ./images/old.png /doc-smith-images "改成 16:9 比例" -u ./images/architecture.png --ratio 16:9
/doc-smith-images "Optimize color scheme and layout" --update ./images/old.png /doc-smith-images "Change to 16:9 ratio" -u ./images/architecture.png --ratio 16:9

组合使用

Combined usage

/doc-smith-images "微服务架构图" --ratio 16:9 --locale zh --savePath ./docs/arch.png
undefined
/doc-smith-images "Microservices architecture diagram" --ratio 16:9 --locale zh --savePath ./docs/arch.png
undefined

选项

Options

OptionAliasDescription
--savePath <path>
图片保存路径(必需)
--ratio <ratio>
-r
宽高比:1:1, 5:4, 4:3, 3:2, 16:9, 21:9(默认 4:3)
--size <size>
-s
图片尺寸:2K, 4K(默认 2K)
--locale <lang>
-l
图片中文字语言(默认 zh)
--update <path>
-u
基于已有图片更新(image-to-image 模式)
--context <text>
-c
提供上下文信息,帮助生成更准确的图片
OptionAliasDescription
--savePath <path>
Image save path (required)
--ratio <ratio>
-r
Aspect ratio: 1:1, 5:4, 4:3, 3:2, 16:9, 21:9 (default 4:3)
--size <size>
-s
Image size: 2K, 4K (default 2K)
--locale <lang>
-l
Language of text in image (default zh)
--update <path>
-u
Update based on existing image (image-to-image mode)
--context <text>
-c
Provide context information to help generate more accurate images

推荐比例

Recommended Ratios

图片类型推荐比例说明
架构图16:9 或 4:3系统架构、模块关系、组件结构
流程图4:3 或 3:2业务流程、数据流向、状态转换
时序图16:9交互时序、调用链路
概念图4:3概念关系、层次结构
示意图4:3 或 1:1功能示意、原理说明
Image TypeRecommended RatioDescription
Architecture Diagram16:9 or 4:3System architecture, module relationships, component structure
Flowchart4:3 or 3:2Business processes, data flows, state transitions
Sequence Diagram16:9Interaction sequences, call chains
Concept Map4:3Concept relationships, hierarchical structures
Schematic Diagram4:3 or 1:1Function illustrations, principle explanations

输出

Output

  • 生成的图片文件路径
  • Path of the generated image file

工作流程

Workflow

根据是否提供
--update
参数,选择不同的工作流程。
Different workflows are selected based on whether the
--update
parameter is provided.

模式 A: 生成新图片(默认)

Mode A: Generate New Image (Default)

当未提供
--update
参数时,生成全新的图片。
调用 AIGNE CLI
<skill-directory>
替换为 skill 实际所在路径。
bash
aigne run <skill-directory>/scripts/aigne-generate save \
  --desc="$PROMPT" \
  --documentContent="$CONTEXT" \
  --locale="$LOCALE" \
  --aspectRatio="$RATIO" \
  --savePath="$OUTPUT_PATH"
AIGNE CLI 参数:
  • --desc
    图片描述/生成提示词
  • --documentContent
    上下文信息(可选)
  • --locale
    图片中文字语言(默认 zh)
  • --aspectRatio
    宽高比(默认 4:3)
  • --savePath
    图片保存路径
When the
--update
parameter is not provided, a completely new image is generated.
Call AIGNE CLI: Replace
<skill-directory>
with the actual path of the skill.
bash
aigne run <skill-directory>/scripts/aigne-generate save \
  --desc="$PROMPT" \
  --documentContent="$CONTEXT" \
  --locale="$LOCALE" \
  --aspectRatio="$RATIO" \
  --savePath="$OUTPUT_PATH"
AIGNE CLI Parameters:
  • --desc
    Image description/generation prompt
  • --documentContent
    Context information (optional)
  • --locale
    Language of text in image (default zh)
  • --aspectRatio
    Aspect ratio (default 4:3)
  • --savePath
    Image save path

模式 B: 编辑已有图片(--update)

Mode B: Edit Existing Image (--update)

当提供
--update
参数时,基于已有图片进行修改(image-to-image 模式)。
使用场景:
  • 图片翻译:将图片中的文字翻译成其他语言
  • 样式调整:修改配色、布局、比例等
  • 内容修改:添加、删除或修改图片中的元素
调用 AIGNE CLI
<skill-directory>
替换为 skill 实际所在路径。
bash
aigne run <skill-directory>/scripts/aigne-generate edit \
  --desc="$EDIT_INSTRUCTION" \
  --sourcePath="$SOURCE_IMAGE" \
  --savePath="$OUTPUT_PATH" \
  --sourceLocale="$SOURCE_LOCALE" \
  --targetLocale="$TARGET_LOCALE" \
  --aspectRatio="$RATIO"
AIGNE CLI 参数(edit 模式):
  • --desc
    编辑要求/修改说明
  • --sourcePath
    源图片路径(要编辑的图片)
  • --savePath
    输出文件路径
  • --sourceLocale
    源图片语言(默认 zh)
  • --targetLocale
    目标语言(翻译场景时使用)
  • --aspectRatio
    宽高比(默认保持原图比例)
图片翻译示例
bash
undefined
When the
--update
parameter is provided, modify based on an existing image (image-to-image mode).
Usage Scenarios:
  • Image translation: Translate text in the image to other languages
  • Style adjustment: Modify color scheme, layout, ratio, etc.
  • Content modification: Add, delete, or modify elements in the image
Call AIGNE CLI: Replace
<skill-directory>
with the actual path of the skill.
bash
aigne run <skill-directory>/scripts/aigne-generate edit \
  --desc="$EDIT_INSTRUCTION" \
  --sourcePath="$SOURCE_IMAGE" \
  --savePath="$OUTPUT_PATH" \
  --sourceLocale="$SOURCE_LOCALE" \
  --targetLocale="$TARGET_LOCALE" \
  --aspectRatio="$RATIO"
AIGNE CLI Parameters (edit mode):
  • --desc
    Editing requirements/modification instructions
  • --sourcePath
    Source image path (image to edit)
  • --savePath
    Output file path
  • --sourceLocale
    Source image language (default zh)
  • --targetLocale
    Target language (used in translation scenarios)
  • --aspectRatio
    Aspect ratio (default retains original image ratio)
Image Translation Example:
bash
undefined

将中文图片翻译成英文

Translate Chinese image to English

aigne run <skill-directory>/scripts/aigne-generate edit
--desc="保持图片的布局和风格不变"
--sourcePath=".aigne/doc-smith/assets/arch/images/zh.png"
--savePath=".aigne/doc-smith/assets/arch/images/en.png"
--sourceLocale="zh"
--targetLocale="en"
--aspectRatio="16:9"

**样式调整示例**:

```bash
aigne run <skill-directory>/scripts/aigne-generate edit
--desc="Keep the layout and style of the image unchanged"
--sourcePath=".aigne/doc-smith/assets/arch/images/zh.png"
--savePath=".aigne/doc-smith/assets/arch/images/en.png"
--sourceLocale="zh"
--targetLocale="en"
--aspectRatio="16:9"

**Style Adjustment Example**:

```bash

修改图片比例和布局

Modify image ratio and layout

aigne run <skill-directory>/scripts/aigne-generate edit
--desc="改成 16:9 比例,使用更清晰的布局"
--sourcePath="./images/old-arch.png"
--savePath="./images/new-arch.png"
--aspectRatio="16:9"
undefined
aigne run <skill-directory>/scripts/aigne-generate edit
--desc="Change to 16:9 ratio with a clearer layout"
--sourcePath="./images/old-arch.png"
--savePath="./images/new-arch.png"
--aspectRatio="16:9"
undefined

验证生成结果

Verify Generation Results

无论哪种模式,都需要检查图片是否成功生成:
bash
ls -la "$OUTPUT_PATH"
file "$OUTPUT_PATH"  # 验证是图片格式
Regardless of the mode, check whether the image was successfully generated:
bash
ls -la "$OUTPUT_PATH"
file "$OUTPUT_PATH"  # Verify it is an image format

返回结果

Return Result

返回生成的图片路径,供调用方使用。
Return the path of the generated image for the caller to use.

与 doc-smith 流程集成

Integration with doc-smith Workflow

当 doc-smith 主流程检测到 AFS Image Slot:
markdown
<!-- afs:image id="architecture" desc="系统架构图,展示各模块关系" -->
主流程通过
generate-slot-image
子代理处理,内部调用 AIGNE CLI: <skill-directory> 替换为 skill 实际所在路径。
bash
aigne run <skill-directory>/scripts/aigne-generate generateAndSave \
  --desc="系统架构图,展示各模块关系" \
  --documentContent="文档内容..." \
  --aspectRatio="4:3" \
  --savePath=".aigne/doc-smith/assets/architecture/images/zh.png"
When the doc-smith main workflow detects an AFS Image Slot:
markdown
<!-- afs:image id="architecture" desc="System architecture diagram showing relationships between modules" -->
The main workflow processes it through the
generate-slot-image
sub-agent, which internally calls the AIGNE CLI: Replace
<skill-directory>
with the actual path of the skill.
bash
aigne run <skill-directory>/scripts/aigne-generate generateAndSave \
  --desc="System architecture diagram showing relationships between modules" \
  --documentContent="Document content..." \
  --aspectRatio="4:3" \
  --savePath=".aigne/doc-smith/assets/architecture/images/zh.png"

注意事项

Notes

  • 此 Skill 依赖 AIGNE 框架执行实际生图
  • 确保 AIGNE CLI 已安装:
    npm install -g @aigne/cli
  • 生图可能需要一定时间,请耐心等待
  • This Skill relies on the AIGNE framework to perform actual image generation
  • Ensure AIGNE CLI is installed:
    npm install -g @aigne/cli
  • Image generation may take some time, please wait patiently

错误处理

Error Handling

AIGNE CLI 未安装

AIGNE CLI Not Installed

错误: aigne 命令未找到

请安装 AIGNE CLI:
npm install -g @aigne/cli
Error: aigne command not found

Please install AIGNE CLI:
npm install -g @aigne/cli

API 密钥未配置

API Key Not Configured

错误: 生图模型认证失败

请执行 `aigne hub connect` 连接到 AIGNE Hub 使用服务,或在环境变量中配置 Google Gemini API 密钥 `GEMINI_API_KEY` 配。
Error: Image generation model authentication failed

Please execute `aigne hub connect` to connect to AIGNE Hub to use the service, or configure the Google Gemini API key `GEMINI_API_KEY` in environment variables.

生图失败

Image Generation Failed

错误: 图片生成失败

可能原因:
1. prompt 描述不清晰
2. 网络连接问题
3. API 配额用尽

建议:
1. 优化 prompt 描述,更具体地说明图片内容
2. 检查网络连接
3. 稍后重试
Error: Image generation failed

Possible causes:
1. Unclear prompt description
2. Network connection issues
3. API quota exhausted

Recommendations:
1. Optimize the prompt description, specify the image content more concretely
2. Check network connection
3. Retry later