关于 image-batch
image-batch 是一项基于 Pillow 和 rembg 的图像批处理技能,面向需要重复处理图片的内容、营销和网站工作流。它通过命令行批量调整尺寸、压缩、移除背景、加水印和转换格式。
主要功能
- 01批量调整尺寸并使用社交平台预设
- 02压缩图片并设置质量或大小上限
- 03移除单张或批量图片背景
- 04添加文字或图片水印
- 05转换为 WebP、AVIF 等格式
适用场景
- 01为多个社交平台制作不同尺寸图片
- 02为电商产品图去背景并统一尺寸
- 03压缩网站图片以优化加载
- 04批量转换旧图片格式并添加水印
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ guia-matthieu/ clawfu-skills --skill image-batch安装后在 Claude Code 中输入/image-batch确认已加载。
附带文件scripts/main.pyscripts/requirements.txt
详细介绍
批量处理图像
使用 Pillow 和 rembg 自动执行重复的图像任务——调整大小、压缩、移除背景,并在几秒内为数百张图像添加水印。
何时使用此技能
- 社交媒体准备 - 一次性为多个平台调整图像大小
- 网站优化 - 压缩并转换为 WebP,以加快加载速度
- 产品照片 - 移除背景,添加统一的样式
- 品牌保护 - 为营销素材添加水印
- 批量转换 - 将旧格式转换为现代格式
Claude 负责什么,哪些由你决定
| Claude 负责 | 由你决定 |
|---|---|
| 组织视频工作流 | 最终创意构想 |
| 建议镜头构图 | 设备选择 |
| 创建分镜模板 | 品牌美学 |
| 生成脚本框架 | 最终批准 |
| 确定技术要求 | 预算分配 |
依赖项
pip install Pillow rembg click
# For GPU-accelerated background removal:
# pip install rembg[gpu]
命令
调整图像大小
python scripts/main.py resize ./images/ --width 1200
python scripts/main.py resize ./images/ --format instagram # 1080x1080
python scripts/main.py resize ./images/ --format linkedin # 1200x627
压缩图像
python scripts/main.py compress ./images/ --quality 80
python scripts/main.py compress ./images/ --max-size 500 # Max 500KB
移除背景
python scripts/main.py remove-bg photo.jpg
python scripts/main.py remove-bg ./products/ --output ./transparent/
添加水印
python scripts/main.py watermark ./images/ --logo logo.png --position bottom-right
python scripts/main.py watermark ./images/ --text "© 2024 Company" --opacity 0.3
转换格式
python scripts/main.py convert ./images/ --format webp
python scripts/main.py convert ./images/ --format avif --quality 80
示例
示例 1:准备电商产品图像
# Remove backgrounds
python scripts/main.py remove-bg ./raw-products/ --output ./transparent/
# Resize to standard size
python scripts/main.py resize ./transparent/ --width 1000 --height 1000 --fit contain
# Compress for web
python scripts/main.py compress ./transparent/ --quality 85 --format webp
# Output: ./transparent/*.webp (optimized, transparent background)
示例 2:社交媒体图像套件
# Create multiple sizes from one source
python scripts/main.py resize hero-image.jpg --format instagram --output hero_ig.jpg
python scripts/main.py resize hero-image.jpg --format linkedin --output hero_li.jpg
python scripts/main.py resize hero-image.jpg --format twitter --output hero_tw.jpg
python scripts/main.py resize hero-image.jpg --format facebook --output hero_fb.jpg
# Or batch process entire folder for one platform
python scripts/main.py resize ./campaign-images/ --format instagram --output ./instagram/
示例 3:优化网站图像
# Convert all images to WebP
python scripts/main.py convert ./website-images/ --format webp --quality 80
# Ensure no image exceeds 200KB
python scripts/main.py compress ./website-images/ --max-size 200
# Results in 60-80% smaller file sizes
社交媒体格式预设
| 格式 | 尺寸 | 宽高比 | 用途 |
|---|---|---|---|
instagram | 1080x1080 | 1:1 | 信息流帖子 |
instagram-story | 1080x1920 | 9:16 | 快拍/Reels |
linkedin | 1200x627 | 1.91:1 | 链接预览 |
linkedin-post | 1200x1200 | 1:1 | 信息流帖子 |
twitter | 1200x675 | 16:9 | 卡片 |
facebook | 1200x630 | 1.91:1 | 链接预览 |
pinterest | 1000x1500 | 2:3 | 图钉 |
youtube | 1280x720 | 16:9 | 缩略图 |
适配模式
| 模式 | 行为 |
|---|---|
cover | 填满区域,裁剪多余部分(默认) |
contain | 在区域内适配,添加留白 |
stretch | 拉伸至精确适配 |
crop | 智能裁剪,聚焦主体 |
输出格式
| 格式 | 最适合 | 压缩 |
|---|---|---|
webp | 网页图像 | 比 JPEG 小 25-35% |
avif | 现代浏览器 | 比 JPEG 小 50% |
jpg | 照片、渐变 | 有损,通用 |
png | 透明图像、图形 | 无损 |
技能边界
此技能擅长的方面
- 组织视频制作工作流
- 创建分镜框架
- 建议技术方案
- 提供创意指导模板
此技能无法做到的事
- 替代专业摄像
- 直接编辑视频文件
- 做出最终创意判断
- 保证观众参与度
相关技能
- video-processing - 处理视频缩略图
- lighthouse-audit - 检查图像对 LCP 的影响
技能元数据
- 模式:cyborg
category: automation
subcategory: image-processing
dependencies: [Pillow, rembg]
difficulty: beginner
time_saved: 5+ hours/week
评论
支持 Markdown