Product photos, design assets, avatar cutouts — they all need a transparent background PNG. With a background removal API you can create one in a single HTTP request. No Photoshop, no manual masking.
Why PNG?
| Format | Transparency | Best For |
|---|---|---|
| JPEG | No | Photos with opaque backgrounds |
| PNG | Yes (alpha channel) | Cutouts, overlays, design assets |
| WebP | Yes | Web delivery (smaller files) |
PNG's alpha channel supports semi-transparent edges — essential for natural-looking cutouts around hair, fur, or glass.
Python Example
import requests
API_URL = "https://background-removal-ai.p.rapidapi.com/remove-background"
HEADERS = {
"x-rapidapi-host": "background-removal-ai.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY",
}
with open("product-photo.jpg", "rb") as f:
resp = requests.post(API_URL, headers=HEADERS, files={"image": f})
data = resp.json()
print(data["image_url"]) # CDN URL of the transparent PNG
# Download the result
png = requests.get(data["image_url"])
with open("transparent-result.png", "wb") as out:
out.write(png.content)
Batch Processing
import os
from concurrent.futures import ThreadPoolExecutor
import requests
def remove_bg(path):
with open(path, "rb") as f:
resp = requests.post(API_URL, headers=HEADERS, files={"image": f})
data = resp.json()
png = requests.get(data["image_url"])
out = path.rsplit(".", 1)[0] + "_transparent.png"
with open(out, "wb") as f:
f.write(png.content)
print(f"Done: {path} -> {out}")
images = [f for f in os.listdir("products") if f.endswith((".jpg", ".png"))]
with ThreadPoolExecutor(max_workers=5) as pool:
pool.map(remove_bg, [f"products/{f}" for f in images])
Beyond Transparency
The same API offers additional endpoints:
-
/blur-background— Blur the background (portrait mode effect) -
/color-background— Replace with a solid color (white for Amazon/Shopify) -
/gradient-background— Replace with a vertical gradient
Use Cases
- E-commerce — White/transparent backgrounds for product catalogs
- Social media — Extract subjects for branded templates and collages
- Print/packaging — Clean cutouts for InDesign/Illustrator compositions
- Web/app UI — Transparent avatars, thumbnails, and icon assets
Optimize File Size
- Resize before uploading (800px is enough for most use cases)
- Quantize with
pngquant --quality=65-80 result.png(60-80% smaller) - Convert to WebP for web delivery:
cwebp -q 80 result.png -o result.webp
👉 Read the full tutorial with cURL, JavaScript examples and edge quality details
Top comments (0)