Smart Photo Editor

Data & APIs

AI-powered photo editing and restoration skill - smart object removal, background removal, old photo restoration, and basic edits.

Install

openclaw skills install smart-photo-editor

Smart Photo Editor Skill

AI-powered photo editing and restoration skill for OpenClaw. Unifies Seedream (AI edits), ImageMagick (basic edits), and OpenCV (programmatic fixes) into one intuitive workflow.

Overview

All-in-one intelligent photo editing skill - automatically selects the best tool for each image processing task.

Key Advantages:

  • Smart Tool Selection - Automatically chooses Seedream / ImageMagick / OpenCV based on task
  • Unified Interface - All operations use the same calling pattern
  • Bilingual Support - Optimized prompts for both Chinese and English contexts
  • Automatic Fallback - Switches to backup tools if primary tool fails
  • Large Image Auto-Handling - Avoids "image too large" API errors

Trigger Conditions

Activates automatically when users mention keywords like:

  • photo editing, edit image, retouch, smart photo edit
  • remove object, delete object, erase
  • remove background, background removal, cutout
  • restore, fix, old photo restoration, repair
  • color adjustment, color correction, color grading
  • crop, resize, compress

Installation & Dependencies

Standard Installation Path

~/.openclaw/skills/smart-photo-editor/

Required & Optional Dependencies

DependencyRequiredPurposeInstallation
byted-ark-seedream-skill✅ RequiredAI object removal, old photo restoration, image-to-image editingRequires VolcEngine Ark API access. Follow official setup guide to enable Seedream model access
imagemagick✅ RequiredBasic image editing (resize, crop, format conversion, color adjustments)sudo apt install imagemagick (Debian/Ubuntu) or brew install imagemagick (macOS)
opencv-python-headless✅ RequiredWire removal, spot removal, image resizingpip install opencv-python-headless
rembg⚠️ OptionalAI-powered background removal (better results for complex scenes)pip install rembg

Install rembg (Optional)

# Install in your virtual environment
source ~/.openclaw/venv-clawd/bin/activate
pip install rembg

VolcEngine Ark Setup

For AI editing features (object removal, photo restoration), ensure:

  1. You have a VolcEngine Ark account with API access
  2. The Seedream (豆包生图) model is enabled for your account
  3. Your OpenClaw configuration has valid VolcEngine API credentials

See the official VolcEngine Ark documentation for detailed setup instructions.


Core Features & Implementation

1. Object Removal

Primary Tool: Seedream Image-to-Image
Fallback Tool: OpenCV Inpainting (small scratches/lines)

Usage:

# AI method (recommended) - complex scenes
image_generate \
  model="byted-ark-seedream-skill" \
  mode="image-to-image" \
  image="/path/to/photo.jpg" \
  reference_strength=0.85 \
  prompt="Remove the [object description] located at [location description]. Restore the seamless texture, keep everything else exactly the same."

# OpenCV method - simple lines/minor imperfections
```bash
# Remove horizontal wire
./scripts/inpaint.py /path/to/photo.jpg /path/to/output.jpg \
  --type wire --y 760 --thickness 10

# Remove diagonal/angled line (supports any angle)
./scripts/inpaint.py /path/to/photo.jpg /path/to/output.jpg \
  --type line --x1 100 --y1 200 --x2 500 --y2 400 --thickness 3

# Remove rectangular region (watermarks, logos, text)
./scripts/inpaint.py /path/to/photo.jpg /path/to/output.jpg \
  --type rect --x 50 --y 50 --w 400 --h 80 --feather 5

# Remove multiple sensor dust spots in one command
./scripts/inpaint.py /path/to/photo.jpg /path/to/output.jpg \
  --type spots --spots "100,150,8;200,300,10;50,400,6"

# Remove multiple lines in one command
./scripts/inpaint.py /path/to/photo.jpg /path/to/output.jpg \
  --type lines --lines "0,100,800,100,3;100,200,500,400,5"

# Batch processing from JSON config
./scripts/inpaint.py /path/to/photo.jpg /path/to/output.jpg \
  --type batch --batch tasks.json

# JSON config example (tasks.json):
# {
#   "operations": [
#     {"type": "spot", "x": 100, "y": 150, "radius": 8},
#     {"type": "spot", "x": 200, "y": 300, "radius": 10},
#     {"type": "wire", "y": 500, "thickness": 5},
#     {"type": "rect", "x": 50, "y": 50, "w": 200, "h": 50, "feather": 10}
#   ]
# }

Algorithm Selection:

  • ns (Navier-Stokes) - Better for textures and larger regions (default for wire/line)
  • telea (Telea) - Faster, better for small regions (default for spot) Use --algo ns or --algo telea to override the default selection.

**Prompt Optimization Examples:**
- "Remove the black power cable at the bottom of the image" → "Remove the thin black horizontal power cable at the bottom 20% of the image. Restore the mountain texture seamlessly, keep everything else exactly the same."
- "Remove the pedestrian in the middle" → "Remove the pedestrian in the center. Fill with matching background texture naturally."

---

### 2. Background Removal
**Primary Tool:** rembg (AI)  
**Fallback Tool:** ImageMagick remove-bg.sh (solid color backgrounds)

**Usage:**
```bash
# rembg AI method (complex backgrounds)
rembg i input.jpg output.png

# ImageMagick method (solid color backgrounds)
./scripts/remove_bg.sh input.png output.png 20 "#FFFFFF"

3. Old Photo Restoration

Primary Tool: Seedream Image-to-Image

Usage:

image_generate \
  model="byted-ark-seedream-skill" \
  mode="image-to-image" \
  image="/path/to/old_photo.jpg" \
  reference_strength=0.7 \
  prompt="Restore this old photo. Remove all scratches, dust spots, and damage. Enhance clarity and contrast. Restore natural, vivid colors while preserving the original photo's character. Do not change the composition or subjects."

4. Basic Editing

Primary Tool: ImageMagick

Common Commands:

# Resize
convert input.jpg -resize 1920x1920\> output.jpg

# Crop
convert input.jpg -crop 800x600+100+50 output.jpg

# Format conversion + compression
convert input.png -quality 85 output.webp

# Color adjustment
convert input.jpg -brightness-contrast 10x5 output.jpg  # Brighter, higher contrast
convert input.jpg -modulate 100,130,100 output.jpg      # Increase saturation
convert input.jpg -grayscale Rec709Luma output.jpg      # Convert to B&W

Unified API Interface

ParameterTypeDefaultRequiredDescription
taskstring-Task type: remove-object / remove-background / restore / resize / crop / color-correct
imagestring-Input image path
promptstring""Object description/location (required for remove-object)
toolstring"auto"Force specific tool: auto / seedream / imagemagick / opencv / rembg
output_formatstring"jpeg"Output format: jpeg / png / webp
qualityinteger95Output quality (0-100)

Intelligent Decision Flow

User request → Analyze task type
    ↓
Object removal? → Seedream (default) → Failed? → OpenCV fallback
    ↓
Background removal? → Detect background → Solid? ImageMagick : rembg
    ↓
Old photo restoration? → Seedream (reference_strength=0.7)
    ↓
Basic editing? → ImageMagick

Examples

Remove Power Cable

Task: Remove the black power cable at the bottom of the image
Parameters:
  task: remove-object
  image: mountain.jpg
  prompt: "Remove the thin black horizontal power cable at the bottom 20% of the image. Restore the mountain texture seamlessly, keep everything else exactly the same."
  tool: seedream

Old Photo Restoration

Task: Restore this old photo
Parameters:
  task: restore
  image: old_photo.jpg
  prompt: "Remove scratches and dust spots, enhance clarity, restore natural colors"

Background Removal

Task: Remove background from portrait photo
Parameters:
  task: remove-background
  image: portrait.jpg
  tool: auto

Error Handling & Fallbacks

  1. Seedream API failure → Automatically try OpenCV inpainting (for wires/scratches)
  2. Image too large → Auto-resize to 2048px max side, process, output
  3. rembg not installed → Auto-fallback to ImageMagick remove-bg
  4. Unsupported format → Auto-convert to JPEG for processing

Large Image Handling Strategy

  • Seedream API limit: ~2048px maximum side length
  • Auto-detect image dimensions, if exceeded:
    1. Proportionally resize to 2048px max side
    2. Perform editing operation
    3. Output processed image
  • Prevents "image too large" errors

Skill File Structure

smart-photo-editor/
├── SKILL.md              # This file
├── README.md             # Quick start guide
├── scripts/
│   ├── inpaint.py        # OpenCV restoration script
│   └── remove_bg.sh      # Background removal wrapper (auto fallback)
└── examples/             # Before/after comparison examples