Remove Background
Batch remove backgrounds from images using rembg (Python library).
When This Skill Activates
- •User says "remove background", "make transparent"
- •User has images that need transparent backgrounds
- •User wants to batch process multiple images
Prerequisites
rembg must be installed:
bash
pip install rembg # or pipx install rembg
Verify installation:
bash
rembg --version
How To Use
Single Image
bash
rembg i INPUT.png OUTPUT.png
Batch Process Directory
IMPORTANT: Never output to the same file - use a separate output directory to avoid corruption.
bash
# Create backup first mkdir -p backup && cp *.png backup/ # Process to separate folder mkdir -p processed for img in *.png; do echo "Processing: $img" rembg i "$img" "processed/$img" done # Verify results, then replace originals mv processed/*.png . && rmdir processed
Process Entire Folder (rembg native)
bash
rembg p INPUT_DIR OUTPUT_DIR
Output Format
- •Input: Any image (PNG, JPG, WEBP)
- •Output: PNG with RGBA (alpha channel for transparency)
Example Workflows
Web Assets
bash
cd ~/projects/my-app/public/images mkdir -p transparent for img in *.png; do rembg i "$img" "transparent/$img"; done
Product Photos
bash
cd ~/products/photos mkdir -p cutout rembg p . cutout/
Models Available
rembg supports different AI models:
| Model | Quality | Speed | Use Case |
|---|---|---|---|
| u2net (default) | Good | Fast | General purpose |
| u2net_human_seg | Better | Medium | People/portraits |
| silueta | Good | Fast | Similar to u2net |
| isnet-general-use | Best | Slower | Complex backgrounds, pixel art, illustrations |
Recommended for pixel art/illustrations: isnet-general-use
Specify model:
bash
rembg i -m isnet-general-use input.png output.png
Troubleshooting
| Issue | Solution |
|---|---|
| Empty output file | Don't use same input/output path - use separate folder |
| Slow first run | Model downloading, wait for it |
| Memory error | Process fewer images at once |
| Poor quality | Try different model with -m flag |
Pro Tips
- •Always backup before batch processing
- •Process to separate folder first, verify, then replace
- •Use
-aflag to keep alpha if image already has transparency - •Post-process in image editor for fine edges if needed