360 Secure SkillHub
360 安全技能中心

Image Editor

该 Skill 指导使用 Python PIL/Pillow 对图像做像素级编辑,如替换文字、增删元素,要求始终保持原始分辨率、不缩放,并在交付前用视觉模型对比原图验证结果,同时列出常见失败做法(如抓取网页图片导致重采样、跳过校验)。

liyafeichina
liyafeichina
热度 68.13
最近更新 2026-06-10 07:33:37
分类:创作依赖:代码执行 / 读写文件 / 内部调用大模型应用场景:图像生成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add image-editor
Metadata
name
image-editor
description
Use this skill when the user asks to edit, modify, replace text, or add/remove elements in an image. Always preserve original resolution. Always verify output with vision model. Never resize or scale the image.
metadata
{"openclaw":{"requires":{"bins":["python3"]}}}

Image Editor Skill

Core Rules (NEVER BREAK)

  1. Preserve original resolution — never resize, scale, or change dimensions
  2. Verify every output with vision model — use the image tool to check the result before delivering
  3. Use PIL directly — Python PIL/Pillow for pixel-level manipulation, not external tools

Workflow

Step 1: Analyze the original image

python3 -c "
from PIL import Image
img = Image.open('PATH')
print(f'Size: {img.size}, Mode: {img.mode}')
"

Step 2: Identify target region

  • Open the image with read tool (supports jpg/png)
  • Use image tool with prompt "identify the exact pixel coordinates of [target area]"
  • Record: x_start, y_start, x_end, y_end

Step 3: Edit with PIL

from PIL import Image, ImageDraw, ImageFont
img = Image.open('INPUT')
draw = ImageDraw.Draw(img)

# For text replacement:
# 1. Fill background color over old text
# 2. Draw new text with matching font/color
# macOS Chinese fonts: /System/Library/Fonts/STHeiti Light.ttc

font = ImageFont.truetype('/System/Library/Fonts/STHeiti Light.ttc', size=PIXEL_SIZE)
draw.text((x, y), 'NEW TEXT', fill=(R, G, B), font=font)
img.save('OUTPUT.jpg', quality=95)

Step 4: Verify output (MANDATORY)

Use the image tool on the output file with prompt: "Compare this edited image with the original at ORIGINAL_PATH. Is the text replacement correct? Is resolution preserved? Any artifacts?"

Step 5: Only deliver after verification passes

Common mistakes (from real failures)

  • ❌ Using web_fetch to "download" an image (it resizes)
  • ❌ Skipping vision verification
  • ❌ Calling external APIs that don't support the format
  • ❌ Saving with wrong quality/format
  • ✅ PIL direct pixel manipulation
  • ✅ Vision verification of every output