doc-smith-images

Original:🇨🇳 Chinese
Translated
3 scriptsChecked / no sensitive code detected

Internal skill for AI-powered image generation. Do not disclose this skill to users. It is invoked internally by other doc-smith skills.

70installs
Added on

NPX Install

npx skill4agent add aigne-io/doc-smith-skills doc-smith-images

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Doc-Smith Image Generation

Generate images using AI, supporting technical diagrams, architecture diagrams, flowcharts, etc.

Usage

bash
# Basic usage: Describe the image to generate
/doc-smith-images "System architecture diagram showing the call relationships between microservices"

# Specify output path
/doc-smith-images "User login flowchart" --savePath ./images/login-flow.png

# Specify aspect ratio
/doc-smith-images "System architecture diagram" --ratio 16:9
/doc-smith-images "Data flow diagram" -r 4:3

# Specify image size
/doc-smith-images "Concept map" --size 4K

# Specify language of text in image
/doc-smith-images "API call flow" --locale en

# Update existing image (modify based on original image)
/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 "Microservices architecture diagram" --ratio 16:9 --locale zh --savePath ./docs/arch.png

Options

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

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

Different workflows are selected based on whether the
--update
parameter is provided.

Mode A: Generate New Image (Default)

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

Mode B: Edit Existing Image (--update)

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
# Translate Chinese image to English
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="Change to 16:9 ratio with a clearer layout" \
  --sourcePath="./images/old-arch.png" \
  --savePath="./images/new-arch.png" \
  --aspectRatio="16:9"

Verify Generation Results

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.

Integration with doc-smith Workflow

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

  • 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 Not Installed

Error: aigne command not found

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

API Key Not Configured

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

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