
background-remover
Remove backgrounds from images using segmentation. Support for color-based, edge detection, and AI-assisted removal methods. Batch processing available.
- Installs
- 122
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill background-remover- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads background-remover automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Background Remover
Remove backgrounds from images using multiple detection methods.
Features
- Color-Based Removal: Remove solid color backgrounds
- Edge Detection: Detect subject edges for removal
- GrabCut Algorithm: Interactive foreground extraction
- Batch Processing: Process multiple images
- Transparency Output: Export with alpha channel
- Background Replacement: Replace with color or image
Quick Start
from background_remover import BackgroundRemover
remover = BackgroundRemover()
# Simple removal
remover.load("photo.jpg")
remover.remove_background()
remover.save("photo_transparent.png")
# Remove specific color
remover.load("product.jpg")
remover.remove_color((255, 255, 255), tolerance=30) # Remove white
remover.save("product_clean.png")
# Replace background
remover.load("portrait.jpg")
remover.remove_background()
remover.replace_background(color=(0, 120, 255)) # Blue background
remover.save("portrait_blue.png")
CLI Usage
# Remove background (auto-detect)
python background_remover.py --input photo.jpg --output result.png
# Remove specific color
python background_remover.py --input image.jpg --color "255,255,255" --tolerance 30 -o clean.png
# Use GrabCut method
python background_remover.py --input photo.jpg --method grabcut -o result.png
# Replace background with color
python background_remover.py --input photo.jpg --replace-color "0,120,255" -o result.png
# Replace background with image
python background_remover.py --input photo.jpg --replace-image bg.jpg -o result.png
# Batch process
python background_remover.py --batch input_folder/ --output-dir output/ --method edge
API Reference
BackgroundRemover Class
class BackgroundRemover:
def __init__(self)
# Loading
def load(self, filepath: str) -> 'BackgroundRemover'
def load_array(self, array: np.ndarray) -> 'BackgroundRemover'
# Removal Methods
def remove_background(self, method: str = "auto") -> 'BackgroundRemover'
def remove_color(self, color: Tuple, tolerance: int = 20) -> 'BackgroundRemover'
def remove_edges(self, threshold: int = 50) -> 'BackgroundRemover'
def grabcut(self, rect: Tuple = None, iterations: int = 5) -> 'BackgroundRemover'
# Background Operations
def replace_background(self, color: Tuple = None, image: str = None) -> 'BackgroundRemover'
def add_shadow(self, offset: Tuple = (5, 5), blur: int = 10) -> 'BackgroundRemover'
# Refinement
def refine_edges(self, feather: int = 2) -> 'BackgroundRemover'
def expand_mask(self, pixels: int = 2) -> 'BackgroundRemover'
def contract_mask(self, pixels: int = 2) -> 'BackgroundRemover'
# Output
def save(self, filepath: str, quality: int = 95) -> str
def get_image(self) -> Image
def get_mask(self) -> Image
# Batch Processing
def batch_process(self, input_dir: str, output_dir: str,
method: str = "auto") -> List[str]
Removal Methods
Auto Detection
# Automatically choose best method
remover.remove_background(method="auto")
Color-Based Removal
# Remove white background
remover.remove_color((255, 255, 255), tolerance=30)
# Remove green screen
remover.remove_color((0, 255, 0), tolerance=50)
# Remove any solid color
remover.remove_color((200, 200, 200), tolerance=40)
Edge Detection
# Use edge detection to find subject
remover.remove_edges(threshold=50)
GrabCut (OpenCV)
# Full image GrabCut
remover.grabcut(iterations=5)
# With bounding rectangle hint
remover.grabcut(rect=(50, 50, 400, 300), iterations=10)
Background Replacement
Solid Color
remover.remove_background()
remover.replace_background(color=(255, 255, 255)) # White
remover.replace_background(color=(0, 0, 0)) # Black
remover.replace_background(color=(135, 206, 235)) # Sky blue
Image Background
remover.remove_background()
remover.replace_background(image="office_bg.jpg")
Transparent (Default)
remover.remove_background()
remover.save("transparent.png") # PNG preserves alpha
Edge Refinement
# Soften edges with feathering
remover.refine_edges(feather=3)
# Expand mask to include more area
remover.expand_mask(pixels=2)
# Contract mask for tighter crop
remover.contract_mask(pixels=2)
Example Workflows
Product Photography
remover = BackgroundRemover()
# Remove white studio background
remover.load("product_photo.jpg")
remover.remove_color((255, 255, 255), tolerance=25)
remover.refine_edges(feather=2)
remover.save("product_transparent.png")
Portrait Editing
remover = BackgroundRemover()
# Remove background from portrait
remover.load("portrait.jpg")
remover.grabcut(iterations=8)
remover.refine_edges(feather=3)
# Add professional background
remover.replace_background(color=(220, 220, 220))
remover.add_shadow(offset=(5, 5), blur=15)
remover.save("portrait_professional.jpg")
Green Screen Removal
remover = BackgroundRemover()
remover.load("greenscreen_video_frame.jpg")
remover.remove_color((0, 255, 0), tolerance=60)
remover.replace_background(image="virtual_bg.jpg")
remover.save("composited.jpg")
Batch Processing
remover = BackgroundRemover()
processed = remover.batch_process(
input_dir="product_photos/",
output_dir="processed/",
method="color",
color=(255, 255, 255),
tolerance=30
)
print(f"Processed {len(processed)} images")
Output Formats
- PNG: Preserves transparency (recommended)
- WEBP: Smaller file, supports alpha
- JPEG: No transparency (use with replace_background)
Tips for Best Results
- White/Solid Backgrounds: Use
remove_color()method - Complex Backgrounds: Use
grabcut()method - High Contrast Subjects: Edge detection works well
- Portraits: GrabCut with edge refinement
- Product Photos: Color removal with feathering
Limitations
- Best results with high contrast between subject and background
- Complex hair/fur edges may need manual touch-up
- Transparent or semi-transparent subjects are challenging
- Very busy backgrounds may require manual assistance
Dependencies
- pillow>=10.0.0
- opencv-python>=4.8.0
- numpy>=1.24.0
- scikit-image>=0.21.0
FAQ
What does the background-remover skill do?
Remove backgrounds from images using segmentation. Support for color-based, edge detection, and AI-assisted removal methods. Batch processing available.
How do I install background-remover?
Run npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill background-remover in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/background-remover/ (personal) or .claude/skills/background-remover/ (project).
Which AI agents can use background-remover?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is background-remover safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains background-remover?
It is published by dkyazzentwatwa in dkyazzentwatwa/chatgpt-skills. It has 122 recorded installs.
More from dkyazzentwatwa/chatgpt-skills
ocr-document-processor
dkyazzentwatwa/chatgpt-skills
Extract text and structure from scans, images, and scanned PDFs. Use for OCR, searchable PDFs, table extraction, receipt parsing, and business card parsing.
crypto-ta-analyzer
dkyazzentwatwa/chatgpt-skills
Run multi-indicator technical analysis on crypto or market OHLCV data. Use for deterministic trend, momentum, volume, and divergence analysis.
text-summarizer
dkyazzentwatwa/chatgpt-skills
Generate extractive summaries from long text documents. Control summary length, extract key sentences, and process multiple documents.
financial-calculator
dkyazzentwatwa/chatgpt-skills
Run loan, investment, NPV, retirement, savings, and risk calculations with schedules and charts. Use for deterministic financial modeling tasks.
document-converter-suite
dkyazzentwatwa/chatgpt-skills
Convert PDFs, Office docs, markdown, HTML, and tables between editable formats. Use for best-effort document conversion, PDF utilities, form filling, and table extraction.
image-enhancement-suite
dkyazzentwatwa/chatgpt-skills
Open the skill to read its SKILL.md instructions.
Popular media & creative skills
hyperframes
heygen-com/hyperframes
Read first to make, edit, animate or render any video with HyperFrames (HTML rendered to video), including launch films, explainers, music videos, charts, maps, vertical clips, title cards, captions and overlays. Holds the render contract, the work loop and what each kind of video needs.
media-use
heygen-com/hyperframes
Get or make any media for a HyperFrames video - music, sound effects, images, icons, logos, voiceover, avatar and generated video, transcripts, cutouts, colour grades and looks - with HeyGen or free local tools, and mix placed audio. Also for footage that looks dark, flat or dull, or should be stylized or hidden.
hyperframes-registry
heygen-com/hyperframes
About 450 ready-made HyperFrames blocks and components installed as editable source - transitions, overlays, titles, kinetic type, captions, charts, map overlays, 3D, camera moves. Use it before hand-building any named visual (CRT scanlines, glitch, film grain, a chart); also for hyperframes add and catalog.
hyperframes-creative
heygen-com/hyperframes
Non-animation creative direction for HyperFrames videos. Use for design spec (frame.md / design.md) handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns, and brand / style decisions. For atomic motion patterns and scene blueprints, use hyperframes-animation.
ai-video-generation
101-skills/superpowers
Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0, HappyHorse 1.0, Wan 2.5, Grok Imagine Video, OmniHuman, Fabric, HunyuanVideo. Capabilities: text-to-video, image-to-video, reference-to-video, video editing, lipsync, avatar animation, video upscaling, foley sound. Use for: social media videos, marketing content, explainer videos, product demos, AI avatars. Triggers: video generation, ai video, text to video, image to video, veo, animate image, video from image, ai animation, video generator, generate video, t2v, i2v, ai video maker, create video with ai, runway alternative, pika alternative, sora alternative, kling alternative, seedance, happyhorse
ai-image-generation
101-skills/superpowers
Generate AI images with GPT-Image-2, FLUX, Gemini, Grok, Seedream, Reve and 50+ models via inference.sh CLI. Models: GPT-Image-2, FLUX Dev LoRA, FLUX.2 Klein LoRA, Gemini 3 Pro Image, Grok Imagine, Seedream 4.5, Reve, ImagineArt. Capabilities: text-to-image, image-to-image, inpainting, LoRA, image editing, upscaling, text rendering. Use for: AI art, product mockups, concept art, social media graphics, marketing visuals, illustrations. Triggers: flux, image generation, ai image, text to image, stable diffusion, generate image, ai art, midjourney alternative, dall-e alternative, text2img, t2i, image generator, ai picture, create image with ai, generative ai, ai illustration, grok image, gemini image, gpt image, openai image, chatgpt image