doc-smith-images
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDoc-Smith 图片生成
Doc-Smith Image Generation
使用 AI 生成图片,支持技术图表、架构图、流程图等。
Generate images using AI, supporting technical diagrams, architecture diagrams, flowcharts, etc.
用法
Usage
bash
undefinedbash
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
| Option | Alias | Description |
|---|---|---|
| 图片保存路径(必需) | |
| | 宽高比:1:1, 5:4, 4:3, 3:2, 16:9, 21:9(默认 4:3) |
| | 图片尺寸:2K, 4K(默认 2K) |
| | 图片中文字语言(默认 zh) |
| | 基于已有图片更新(image-to-image 模式) |
| | 提供上下文信息,帮助生成更准确的图片 |
| Option | Alias | Description |
|---|---|---|
| Image save path (required) | |
| | Aspect ratio: 1:1, 5:4, 4:3, 3:2, 16:9, 21:9 (default 4:3) |
| | Image size: 2K, 4K (default 2K) |
| | Language of text in image (default zh) |
| | Update based on existing image (image-to-image mode) |
| | 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 Type | Recommended Ratio | Description |
|---|---|---|
| Architecture Diagram | 16:9 or 4:3 | System architecture, module relationships, component structure |
| Flowchart | 4:3 or 3:2 | Business processes, data flows, state transitions |
| Sequence Diagram | 16:9 | Interaction sequences, call chains |
| Concept Map | 4:3 | Concept relationships, hierarchical structures |
| Schematic Diagram | 4:3 or 1:1 | Function illustrations, principle explanations |
输出
Output
- 生成的图片文件路径
- Path of the generated image file
工作流程
Workflow
根据是否提供 参数,选择不同的工作流程。
--updateDifferent workflows are selected based on whether the parameter is provided.
--update模式 A: 生成新图片(默认)
Mode A: Generate New Image (Default)
当未提供 参数时,生成全新的图片。
--update调用 AIGNE CLI:
替换为 skill 实际所在路径。
<skill-directory>bash
aigne run <skill-directory>/scripts/aigne-generate save \
--desc="$PROMPT" \
--documentContent="$CONTEXT" \
--locale="$LOCALE" \
--aspectRatio="$RATIO" \
--savePath="$OUTPUT_PATH"AIGNE CLI 参数:
- 图片描述/生成提示词
--desc - 上下文信息(可选)
--documentContent - 图片中文字语言(默认 zh)
--locale - 宽高比(默认 4:3)
--aspectRatio - 图片保存路径
--savePath
When the parameter is not provided, a completely new image is generated.
--updateCall AIGNE CLI:
Replace with the actual path of the skill.
<skill-directory>bash
aigne run <skill-directory>/scripts/aigne-generate save \
--desc="$PROMPT" \
--documentContent="$CONTEXT" \
--locale="$LOCALE" \
--aspectRatio="$RATIO" \
--savePath="$OUTPUT_PATH"AIGNE CLI Parameters:
- Image description/generation prompt
--desc - Context information (optional)
--documentContent - Language of text in image (default zh)
--locale - Aspect ratio (default 4:3)
--aspectRatio - Image save path
--savePath
模式 B: 编辑已有图片(--update)
Mode B: Edit Existing Image (--update)
当提供 参数时,基于已有图片进行修改(image-to-image 模式)。
--update使用场景:
- 图片翻译:将图片中的文字翻译成其他语言
- 样式调整:修改配色、布局、比例等
- 内容修改:添加、删除或修改图片中的元素
调用 AIGNE CLI:
替换为 skill 实际所在路径。
<skill-directory>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 - 源图片语言(默认 zh)
--sourceLocale - 目标语言(翻译场景时使用)
--targetLocale - 宽高比(默认保持原图比例)
--aspectRatio
图片翻译示例:
bash
undefinedWhen the parameter is provided, modify based on an existing image (image-to-image mode).
--updateUsage 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 with the actual path of the skill.
<skill-directory>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):
- Editing requirements/modification instructions
--desc - Source image path (image to edit)
--sourcePath - Output file path
--savePath - Source image language (default zh)
--sourceLocale - Target language (used in translation scenarios)
--targetLocale - Aspect ratio (default retains original image ratio)
--aspectRatio
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"
--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"
**样式调整示例**:
```bashaigne 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"
--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"
--desc="改成 16:9 比例,使用更清晰的布局"
--sourcePath="./images/old-arch.png"
--savePath="./images/new-arch.png"
--aspectRatio="16:9"
undefinedaigne 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"
--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="系统架构图,展示各模块关系" -->主流程通过 子代理处理,内部调用 AIGNE CLI:
<skill-directory> 替换为 skill 实际所在路径。
generate-slot-imagebash
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 sub-agent, which internally calls the AIGNE CLI: Replace with the actual path of the skill.
generate-slot-image<skill-directory>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/cliError: aigne command not found
Please install AIGNE CLI:
npm install -g @aigne/cliAPI 密钥未配置
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