image-studio图片处理

👤 user_3b76b7e2 📦 v1.0.0 ⭐ 4.5 ⬇️ 882 下载
🎨 设计多媒体 免费

📖 技能介绍


name: image-studio displayName: "Image Studio — 批量图像处理" allowed-tools: Bash(python *) description: > Batch image processing tool supporting remove background (抠图), replace background (换背景), add watermark (水印), and resize/crop (尺寸裁剪). Processes single images or entire directories in batch mode. Supported formats: PNG, JPG, JPEG, WEBP, BMP, TIFF. Uses a local Python CLI (image_studio.py) backed by rembg + Pillow — no API keys or network required after dependency install. triggers: image-studio, 抠图, 换背景, 水印, 裁剪, remove background, replace background, watermark, resize image, batch image processing homepage: "" license: MIT


Image Studio — 批量抠图,换背景,水印添加、尺寸裁剪

A local CLI tool for batch image processing. All operations run offline on your machine using Python — no cloud API, no data leaves your computer.

7w4.net提供免费和付费技能下载。

Quick links: remove-bg · replace-bg · watermark · resize

Skill location

The Python CLI lives at:

~/.agents/skills/image-studio/image_studio.py

All commands use python <path>/image_studio.py <command> ....


First-time setup

# Install the one external dependency
python ~/.agents/skills/image-studio/image_studio.py install

Or manually:

pip install rembg

rembg is only needed for remove-bg and replace-bg. The other commands (watermark, resize, info) work with just Pillow (pre-installed).


Commands

1. 抠图 — remove-bg

Remove background from image(s). Uses AI-based rembg (u2net model).

# Single image
python ~/.agents/skills/image-studio/image_studio.py remove-bg \
  -i input.jpg \
  -o ./output

# Batch — entire directory
python ~/.agents/skills/image-studio/image_studio.py remove-bg \
  -i ./images/ \
  -o ./output_nobg

# Chinese alias
python ~/.agents/skills/image-studio/image_studio.py 抠图 \
  -i photo.jpg \
  -o ./output
Flag Description Default
-i / --inputs Input file(s) or directory (required)
-o / --output-dir Output directory ./output_nobg
--model rembg model name (u2net, u2netp, u2net_human_seg, etc.) u2net

Fallback: If rembg is not installed, the skill falls back to OpenCV GrabCut (less accurate but dependency-free).

2. 换背景 — replace-bg

Remove background and composite the subject onto a new background (image or solid color).

# Replace with image
python ~/.agents/skills/image-studio/image_studio.py replace-bg \
  -i portrait.jpg \
  -b beach_background.jpg \
  -o ./output

# Replace with solid color
python ~/.agents/skills/image-studio/image_studio.py replace-bg \
  -i product.jpg \
  --bg-color "#3498db" \
  -o ./output

# Batch replace
python ~/.agents/skills/image-studio/image_studio.py replace-bg \
  -i ./photos/ \
  -b studio_bg.jpg \
  -o ./output_newbg
Flag Description Default
-i / --inputs Input file(s) or directory (required)
-b / --background Background image path
--bg-color Solid background color (hex) #ffffff
-o / --output-dir Output directory ./output_newbg

-b and --bg-color are mutually exclusive.

3. 水印 — watermark

Add text or image watermark with configurable position, opacity, and size.

# Text watermark
python ~/.agents/skills/image-studio/image_studio.py watermark \
  -i photo.jpg \
  -t "© 2024 Your Name" \
  -p bottom-right \
  --opacity 0.6 \
  --font-size 48 \
  --font-color "#ffffff" \
  -o ./output

# Image watermark (logo)
python ~/.agents/skills/image-studio/image_studio.py watermark \
  -i photo.jpg \
  --image logo.png \
  --scale 0.15 \
  -p bottom-right \
  --opacity 0.8 \
  -o ./output

# Tiled watermark (full coverage)
python ~/.agents/skills/image-studio/image_studio.py watermark \
  -i document.jpg \
  -t "DRAFT" \
  -p tile \
  --opacity 0.3 \
  -o ./output

# Batch watermark
python ~/.agents/skills/image-studio/image_studio.py watermark \
  -i ./photos/ \
  -t "© 2024" \
  -p bottom-right \
  -o ./output_wm
Flag Description Default
-i / --inputs Input file(s) or directory (required)
-t / --text Watermark text
--image Watermark image path
-p / --position top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right, tile bottom-right
--opacity Opacity 0 (transparent) – 1 (solid) 0.5
--font-size Font size in px (text only) 36
--font-color Font hex color (text only) #ffffff
--scale Watermark size ratio 0–1 relative to image width (image only) 0.1

-t and --image are mutually exclusive.

4. 尺寸裁剪 — resize

Resize or crop image(s) to target dimensions. Four modes:

Mode Description
resize Stretch to exact dimensions (may distort)
cover Fill target entirely, crop overflow (like CSS object-fit: cover)
contain Fit inside target with letterbox bars (like CSS object-fit: contain)
crop Center-crop to target aspect ratio, then resize
# Cover mode (default) — best for thumbnails/banners
python ~/.agents/skills/image-studio/image_studio.py resize \
  -i photo.jpg \
  -w 1920 -h 1080 \
  --mode cover \
  -o ./output

# Contain mode — with letterbox bg
python ~/.agents/skills/image-studio/image_studio.py resize \
  -i photo.jpg \
  -w 800 -h 800 \
  --mode contain \
  --bg-color "#000000" \
  -o ./output

# Crop mode — center crop to ratio
python ~/.agents/skills/image-studio/image_studio.py resize \
  -i photo.jpg \
  -w 1080 -h 1080 \
  --mode crop \
  -o ./output

# Batch resize all images in a folder
python ~/.agents/skills/image-studio/image_studio.py resize \
  -i ./images/ \
  -w 800 -h 600 \
  --mode cover \
  -o ./output_resize
Flag Description Default
-i / --inputs Input file(s) or directory (required)
-w / --width Target width in px (required)
-h / --height Target height in px (required)
--mode resize | cover | contain | crop cover
--bg-color Letterbox color (contain mode only) #000000
--format Output format: png or jpg png

5. 信息 — info

Show image metadata (dimensions, mode, file size).

python ~/.agents/skills/image-studio/image_studio.py info \
  -i photo.jpg

python ~/.agents/skills/image-studio/image_studio.py info \
  -i ./images/

Batch processing patterns

All commands accept directories as -i input. They scan for supported formats: .png, .jpg, .jpeg, .webp, .bmp, .tiff.

Pipeline: batch remove background → replace → resize → watermark

SKILL=~/.agents/skills/image-studio/image_studio.py
DIR=./batch

# Step 1: Remove backgrounds
python $SKILL remove-bg -i $DIR/photos -o $DIR/step1_nobg

# Step 2: Replace with new background
python $SKILL replace-bg -i $DIR/step1_nobg -b bg.jpg -o $DIR/step2_newbg

# Step 3: Resize to uniform size
python $SKILL resize -i $DIR/step2_newbg -w 1920 -h 1080 --mode cover -o $DIR/step3_resize

# Step 4: Add watermark
python $SKILL watermark -i $DIR/step3_resize -t "© 2024" -p bottom-right -o $DIR/final

Error handling

Scenario Behavior
No supported files found Exit with "No supported image files found." message
rembg not installed for remove-bg/replace-bg Auto-fallback to OpenCV GrabCut (less accurate)
Invalid hex color Falls back to white
Unknown position Warns and uses bottom-right
Directory doesn't exist Created automatically for -o; errors for -i
Unsupported format Skipped silently (only supported extensions are processed)

First-use checklist

  1. Install rembg (once): python ~/.agents/skills/image-studio/image_studio.py install
  2. Verify: python ~/.agents/skills/image-studio/image_studio.py info -i any_image.jpg

How to invoke this skill

The user activates this skill by typing /image-studio or any trigger keyword. When invoked:

  1. Check if rembg is available if the task involves background removal. If not, suggest running pip install rembg or the install sub-command.
  2. Determine which operation(s) the user needs (remove-bg, replace-bg, watermark, resize).
  3. For the requested operation, construct the appropriate python image_studio.py ... command.
  4. Run the command and report results to the user (number of images processed, output location).
  5. If the user needs a multi-step pipeline, chain commands sequentially.

All output preserves RGBA transparency where applicable. PNG is the default output format for transparency support.

🤖 AI 评测

这是一个功能丰富、质量较高的图像处理 Skill,核心功能齐全且支持批量操作,离线运行无需网络。文档清晰易懂,中文命令对国内用户友好。rembg 缺失时能自动降级保证了可用性。主要不足是缺少测试和示例文件,且水印功能在某些环境下可能无法正确显示中文。总体而言是个好用的工具,适合需要批量处理图片的用户。

📊 多维度评分

适应性4.2
规范性4.2
有效性4.7
可靠性4.5
可信度5

📁 包含文件 (2 个)

📄 SKILL.md 8.7 KB
📄 image_studio.py 17.9 KB