image-gen

GitHub

指导在沙箱环境中使用Matplotlib和Pillow生成图表、绘图及图像,并强调通过Base64内联方式展示结果。

skills/image-gen/SKILL.md fastclaw-ai/fastclaw

Trigger Scenarios

用户要求绘制图表或数据可视化 用户要求创建或编辑图像

Install

npx skills add fastclaw-ai/fastclaw --skill image-gen -g -y
More Options

Use without installing

npx skills use fastclaw-ai/fastclaw@image-gen

指定 Agent (Claude Code)

npx skills add fastclaw-ai/fastclaw --skill image-gen -a claude-code -g -y

安装 repo 全部 skill

npx skills add fastclaw-ai/fastclaw --all -g -y

预览 repo 内 skill

npx skills add fastclaw-ai/fastclaw --list

SKILL.md

Frontmatter
{
    "name": "image-gen",
    "metadata": {
        "fastclaw": {
            "always": false
        }
    },
    "description": "Generate images, charts, plots, and visualizations. Use when the user asks to draw, plot, chart, visualize data, or create images."
}

Image Generation Skill

Generate images in the headless sandbox using Python libraries.

Available Libraries

Matplotlib (charts, plots, graphs)

import matplotlib
matplotlib.use('Agg')  # REQUIRED: headless backend
import matplotlib.pyplot as plt

plt.figure(figsize=(10, 6))
plt.plot([1, 2, 3], [1, 4, 9])
plt.title('My Chart')
plt.savefig('/tmp/chart.png', dpi=150, bbox_inches='tight')

PIL/Pillow (drawing, image manipulation)

from PIL import Image, ImageDraw, ImageFont
img = Image.new('RGB', (400, 300), 'white')
draw = ImageDraw.Draw(img)
draw.rectangle([50, 50, 350, 250], outline='black', width=2)
img.save('/tmp/drawing.png')

CRITICAL: Displaying Images to User

After generating an image, always output it as inline base64 markdown so it renders in chat:

import base64
with open('/tmp/output.png', 'rb') as f:
    b64 = base64.b64encode(f.read()).decode()
print(f'![image](data:image/png;base64,{b64})')

Do this in the same exec call as the image generation. The markdown image tag will render directly in the chat.

Guidelines

  • Always use matplotlib.use('Agg') before importing pyplot
  • NEVER use turtle, tkinter, pygame, or any GUI library
  • Save images to /tmp/ directory
  • Always output base64 inline — don't just report the file path
  • For charts: use clear labels, titles, and legends
  • Install missing packages with pip if needed: pip install matplotlib pillow

Version History

  • beee30c Current 2026-07-25 08:17

Same Skill Collection

internal/agent/bundled_skills/camoufox-cli/SKILL.md
internal/agent/bundled_skills/skill-creator/SKILL.md
skills/code-runner/SKILL.md
skills/data-analysis/SKILL.md
skills/fastclaw-skill-guide/SKILL.md
skills/fastclaw-skill-learner/SKILL.md
skills/skill-creator/SKILL.md
skills/translation/SKILL.md
skills/web-search/SKILL.md
internal/agent/bundled_skills/find-skills/SKILL.md
skills/find-skills/SKILL.md

Metadata

Files
0
Version
533a138
Hash
5146663f
Indexed
2026-07-25 08:17

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-27 16:19
浙ICP备14020137号-1 $Carte des visiteurs$