name: image-batch-processor description: 圖片批次處理工具箱。當用戶需要批次處理圖片時使用:格式互轉(PNG/JPG/HEIC/LIVP/CR2/ARW/NEF/WebP/TIFF/SVG/PDF 等)、新增文字或圖片水印、壓縮體積、OCR 提取文字、水平/垂直拼接長圖、按行列拆分、灰度調整、按畫素或百分比縮放、旋轉、水平/垂直翻轉、模糊轉高畫質/超分放大、圖片背景去除。適用於"把圖片轉成xxx格式""加個水印""壓縮一下圖片""提取這張圖裡的文字""拼成長圖""把大圖分成九宮格""讓模糊圖片變清晰""摳圖去背景"等請求。 agent_created: true
一個面向批次圖片處理的單檔案 CLI 技能,覆蓋截圖工具類網站常見的十二類操作:格式互轉、水印、壓縮、OCR 文字提取、長圖拼接、網格拆分、灰度、縮放、旋轉、翻轉、模糊轉高畫質/超分放大、圖片背景去除。所有操作均支援批次(目錄 / 萬用字元),失敗時跳過並彙總,不中斷整體任務。
核心指令碼:scripts/image_batch_processor.py(基於 Pillow,可選依賴按需啟用)。
觸發詞與場景示例:
小蔥技能有更好的技能skills外掛。
Pillow(py3)
bash
pip install Pillowpillow-heifrawpycairosvgpytesseract + 系統安裝 Tesseract(中文包 chi_sim)img2pdfrembg(基於 ONNX Runtime,效果最好)realesrgan + numpy + 對應 .pth 模型檔案建議在虛擬環境或隔離目錄安裝,避免汙染使用者環境。
scripts/image_batch_processor.py 對應子命令。可用 --out 指定輸出目錄,否則預設寫入 <輸入目錄>/<操作>_output。指令碼統一入口:
python scripts/image_batch_processor.py <子命令> <輸入...> [選項]
python scripts/image_batch_processor.py convert "*.png" --format jpg --quality 92
python scripts/image_batch_processor.py convert ./raw/ --format webp --recursive
python scripts/image_batch_processor.py convert photo.heic --format jpg # 需 pillow-heif
--format:目標格式(jpg/png/gif/bmp/webp/tiff/ico/pdf/svg/heic/heif/psd…)--quality:有損格式質量(1-100,預設 95)python scripts/image_batch_processor.py watermark "*.jpg" --text "© 2026" --opacity 0.6 --position bottomright
python scripts/image_batch_processor.py watermark "*.png" --logo ./logo.png --scale 0.2
--text / --logo 可單獨或同時用。--scale:logo 相對圖片寬度的比例(預設 0.2)。--opacity:文字透明度 0-1。--position:center / topleft / topright / bottomleft / bottomright。python scripts/image_batch_processor.py compress ./photos/ --quality 70
--quality:JPEG 質量(預設 70),列印壓縮前後體積與節省比例。python scripts/image_batch_processor.py ocr ./scans/ --lang chi_sim+eng
.txt;需 pytesseract + Tesseract 引擎。python scripts/image_batch_processor.py stitch 1.png 2.png 3.png --direction vertical --name long.png
python scripts/image_batch_processor.py stitch ./slides/ --direction horizontal
--direction:vertical(預設)/ horizontal;拼接前統一對齊邊。python scripts/image_batch_processor.py split big.png --rows 3 --cols 3
<原圖名>_行_列.png,如 big_1_1.png … big_3_3.png。python scripts/image_batch_processor.py grayscale "*.jpg" --level 50
--level:0=純灰,100=原色(預設 50)。python scripts/image_batch_processor.py resize "*.png" --width 800
python scripts/image_batch_processor.py resize "*.png" --percent 50
python scripts/image_batch_processor.py resize "*.png" --width 1920 --height 1080
python scripts/image_batch_processor.py rotate "*.jpg" --angle 90
python scripts/image_batch_processor.py flip "*.jpg" --direction horizontal
python scripts/image_batch_processor.py enhance blurry.jpg --scale 2
python scripts/image_batch_processor.py enhance ./low_res/ --scale 4 --model RealESRGAN_x4plus.pth
--scale:放大倍數 2/3/4(預設 2)。--model:可選 Real-ESRGAN 模型路徑;未提供則使用 Pillow LANCZOS + 非銳化掩膜的基礎增強。--model-arch:general(預設)/ anime。python scripts/image_batch_processor.py removebg photo.jpg
python scripts/image_batch_processor.py removebg ./products/ --tolerance 25
rembg(AI 摳圖,效果最佳);未安裝時自動回退到「四角取色 + 顏色容差」簡單摳圖。--tolerance:回退模式下背景顏色容差(預設 30)。--out。msyh.ttc、macOS PingFang.ttc 等),缺失時回退預設字型,文字水印仍可用。img2pdf 增強(見 Dependencies)。.pth 模型並通過 --model 指定。rembg 與 ONNX Runtime,首次安裝可能較大;簡單背景可依賴無依賴回退模式。這是一款非常實用的圖片批次處理工具,功能齊全、操作簡便,適合日常使用。批次處理能力強,處理失敗的圖片不會中斷整體任務,這點很貼心。文件寫得很清楚,普通人也能看懂。不過部分高階功能(如 AI 摳圖、超分高畫質)需要額外安裝依賴才能使用,而且文字水印只能放在底部居中位置,位置選擇沒有文件說的那麼靈活。整體質量不錯,日常圖片處理需求基本都能滿足。