withoutbg is a specialized AI tool designed for precise image background removal. It offers the flexibility of running tasks locally for free or utilizing a cloud API for superior results. Supporting both single images and batch processing, the tool is accessible via a Python API or a Command Line Interface (CLI). withoutbg is engineered for sharp edge detection and preserves intricate details such as hair and fur, producing clean, transparent backgrounds ideal for e-commerce product photography and automated social media content creation.
Two Processing Modes:
Advanced Detail Preservation: Features accurate edge detection and restores fine details effectively. The output is a high-quality image with a transparent background.
Install the package using pip. Open your terminal and execute:
pip install withoutbg
Local Single Image:
withoutbg image.jpg – This command strips the background from image.jpg.
Cloud API (Higher Quality):
First, obtain an API key from the provider. Then run:
withoutbg image.jpg --api-key sk_your_api_key (ensure you replace sk_your_api_key with your actual credentials).
Background removal requires only a few lines of Python code, whether you are using local processing or the cloud service. Batch operations are also natively supported.
from withoutbg import remove_background
result = remove_background("input.jpg")
result.save("output.png")
from withoutbg import remove_background
result = remove_background("input.jpg", api_key="sk_your_key")
from withoutbg import remove_background_batch
results = remove_background_batch(["img1.jpg", "img2.jpg"],
output_dir="results/")
The command line interface offers extensive control over output paths, file formats, quality settings, and cloud API integration.
Core Commands:
Process a single image and define a specific output path:
withoutbg photo.jpg --output result.png
Define a custom file format and compression quality:
withoutbg photo.jpg --format webp --quality 90
Cloud API via CLI:
Configure your API key as an environment variable:
export WITHOUTBG_API_KEY="sk_your_api_key"
Then execute:
withoutbg photo.jpg --use-api
Alternatively, pass the key directly within the command:
withoutbg photo.jpg --api-key sk_your_key
Batch Processing:
Process every image within a specific folder:
withoutbg photos/ --batch --output-dir results/
Execute batch processing using the cloud API:
withoutbg photos/ --batch --use-api --output-dir results/
To contribute to the project or customize the tool, clone the repository and install it in editable mode:
git clone https://github.com/withoutbg/withoutbg.gitcd withoutbgpip install -e ".[dev]"For a standard implementation where you simply need to remove the background:
import withoutbg
output = withoutbg.remove_background("portrait.jpg")
output.save("portrait-withoutbg.png")
For online retailers managing high volumes of inventory, batch processing significantly reduces manual work:
import withoutbg
from pathlib import Path
product_images = Path("products").glob("*.jpg")
results = withoutbg.remove_background_batch(
list(product_images),
output_dir="catalog-withoutbg/",
api_key="sk_your_key" # Cloud API recommended for professional quality
)
Extract subjects from their original backgrounds and composite them onto custom backdrops:
import withoutbg
from PIL import Image
foreground = withoutbg.remove_background("selfie.jpg", api_key="sk_key")
background = Image.open("gradient_bg.jpg")
background.paste(foreground, (0, 0), foreground)
background.save("social_post.jpg")
To access the cloud API, register for a key at withoutbg.com. You can configure it using either of the following methods:
export WITHOUTBG_API_KEY="sk_your_api_key"result = withoutbg.remove_background("image.jpg", api_key="sk_your_key")git clone https://github.com/withoutbg/withoutbg.gitcd withoutbgpip install -e ".[dev]"pytestblack src/ tests/ and ruff check src/ tests/mypy src/Monitor your API consumption through the StudioAPI:
from withoutbg.api import StudioAPI
api = StudioAPI(api_key="sk_your_key")
usage = api.get_usage()
print(usage)
Tiny Qwen: A Clean PyTorch Implementation of Qwen3 and Qwen2.5-VL
Qwen3-ASR-Studio: Real-Time Voice Recognition with PiP Mode
PandaWiki Setup Guide: Building an AI-Powered Knowledge Base
Build AI Agent Interfaces Faster with agents-ui-kit
Transformers Library: Installation, Pipeline API, and Model Examples
Flameshot CLI Guide: Capture, Edit, and Upload Screenshots Rapidly
How to Install and Use Vosk Offline Speech Recognition
AgentCPM-GUI: A Local LLM Agent for Navigating Chinese Mobile Apps
ZeroSearch: Training LLMs to Search Without Real-World Search Engines
MCP SuperAssistant: Bring MCP Tools to ChatGPT, Gemini, and Beyond
SuperCoder: A Terminal-Based Coding Assistant for Searching, Editing, and Debugging
Liebao VPN: Download, Install & Use on Android & iOS