← 返回
未分类

image-studio图片处理

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.
>批量抠图、换背景、水印添加、尺寸裁剪
user_3b76b7e2
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 108
下载
💾 0
安装
1
版本
#latest

概述

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.

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 /image_studio.py ....


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
FlagDescriptionDefault
---------
-i / --inputsInput file(s) or directory (required)
-o / --output-dirOutput directory./output_nobg
--modelrembg 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
FlagDescriptionDefault
---------
-i / --inputsInput file(s) or directory (required)
-b / --backgroundBackground image path
--bg-colorSolid background color (hex)#ffffff
-o / --output-dirOutput 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
FlagDescriptionDefault
---------
-i / --inputsInput file(s) or directory (required)
-t / --textWatermark text
--imageWatermark image path
-p / --positiontop-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right, tilebottom-right
--opacityOpacity 0 (transparent) – 1 (solid)0.5
--font-sizeFont size in px (text only)36
--font-colorFont hex color (text only)#ffffff
--scaleWatermark 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:

ModeDescription
------
resizeStretch to exact dimensions (may distort)
coverFill target entirely, crop overflow (like CSS object-fit: cover)
containFit inside target with letterbox bars (like CSS object-fit: contain)
cropCenter-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
FlagDescriptionDefault
---------
-i / --inputsInput file(s) or directory (required)
-w / --widthTarget width in px (required)
-h / --heightTarget height in px (required)
--moderesize \cover \contain \cropcover
--bg-colorLetterbox color (contain mode only)#000000
--formatOutput format: png or jpgpng

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

ScenarioBehavior
------
No supported files foundExit with "No supported image files found." message
rembg not installed for remove-bg/replace-bgAuto-fallback to OpenCV GrabCut (less accurate)
Invalid hex colorFalls back to white
Unknown positionWarns and uses bottom-right
Directory doesn't existCreated automatically for -o; errors for -i
Unsupported formatSkipped 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.

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-05-17 19:27 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

design-media

Nano Banana Pro

steipete
使用 Nano Banana Pro (Gemini 3 Pro Image) 生成或编辑图像。支持文生图、图生图及 1K/2K/4K 分辨率,适用于图像创建、修改及编辑请求,使用 --input-image 指定输入图像。
★ 424 📥 116,179
design-media

Openai Whisper

steipete
使用 Whisper CLI 进行本地语音转文字(无需 API 密钥)
★ 329 📥 92,885
design-media

UI/UX Pro Max

xobi667
提供 UI/UX 设计智能与实现指导,帮助打造精美界面。适用于 UI 设计、UX 流程、信息架构、视觉风格、设计系统/标记、组件规格、文案/微文案、无障碍及前端 UI(HTML/CSS/JS、React、Next.js、Vue、Svelte
★ 216 📥 46,533