# AI Background Remover (Transparent PNG, No API Key) (`freecamp008/background-remover`) Actor

Remove the background from any image and get a transparent PNG or WebP cutout. Self-hosted IS-Net and U2-Net AI models, optional solid background color, crop to subject and mask output. No external APIs.

- **URL**: https://apify.com/freecamp008/background-remover.md
- **Developed by:** [Camp8 fr0](https://apify.com/freecamp008) (community)
- **Categories:** AI, Developer tools, For creators
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.00 / 1,000 image processeds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## AI Background Remover: Remove Image Backgrounds to Transparent PNG (No API Key)

Remove the background from any photo and get a **transparent PNG or WebP cutout** in seconds. The Actor runs open-source AI segmentation models (**IS-Net** and **U2-Net**, the same models used by the popular `rembg` tool) on Apify. No remove.bg or other paid API, no API key, and your images are never sent to a third-party service.

### What does Background Remover do?

Give it a list of image URLs. For each image, the Actor:

1. downloads and decodes the image (JPEG, PNG, WebP, AVIF, GIF, TIFF; EXIF rotation is applied),
2. predicts a foreground mask with the AI model you choose,
3. uses the mask as the alpha channel and saves a **transparent PNG/WebP**, or flattens it onto a **solid background color**,
4. optionally **crops to the subject** and saves the **grayscale mask**,
5. returns a dataset row with a public link to the result plus size, foreground ratio and timing.

Pre- and post-processing reproduce `rembg` step by step: the same resize filter, normalization and min-max mask scaling. On our test images the masks match `rembg` within 1/255.

### Key features

- **Self-hosted AI models**: IS-Net general-use (best quality, default), U2-Net, U2-Net-P (fast), Silueta and U2-Net human segmentation for portraits. All are open source and licensed for commercial use.
- **Transparent PNG or WebP** output. WebP files are often 5-10x smaller and keep transparency.
- **Background color replacement**: put the cutout on white (`#ffffff`) for Amazon, eBay or Shopify product photos, or on any other hex color.
- **Crop to subject**: removes the empty margins around the subject.
- **Mask export**: get the black-and-white segmentation mask for your own compositing.
- **Edge controls**: an optional hard threshold and feather (a lightweight alpha-matting step) to clean up halos.
- **Large images**: inputs are downscaled to `maxSidePx` (default 4096 px), so time and memory stay predictable.
- **Fast HTTP API (Standby mode)**: call it like a regular REST endpoint and optionally get the PNG back as base64 in the response.
- **Pay per image**. Images that fail (broken links, non-image files) are reported but **not charged**.

### Use cases

- **E-commerce product photos**: white or transparent backgrounds for marketplaces and catalogs.
- **Profile pictures and headshots**: clean portrait cutouts for team pages, ID-style photos and avatars.
- **Marketing and design**: stickers, thumbnails, banners and social media creatives.
- **Real estate, car dealers and classifieds**: isolate the item from a cluttered background.
- **AI and data pipelines**: build segmentation datasets, generate masks, or preprocess images for other models.
- **Automation**: connect it to Make, Zapier, n8n or your own backend to process every new upload automatically.

### How to use Background Remover

#### In Apify Console

1. Open the Actor and paste one or more image URLs into **Image URLs**.
2. Choose a **model**. `isnet-general-use` is the best default; `u2netp` is the fastest.
3. Optional: set a **background color**, enable **Crop to subject**, or choose **WebP** output.
4. Click **Start**. Each result row links to the finished cutout in the run's key-value store.

#### Via the Apify API

```bash
curl -X POST "https://api.apify.com/v2/acts/freecamp008~background-remover/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/portrait-of-woman_small.jpg"], "outputFormat": "png"}'
```

You can also use the official `apify-client` packages for JavaScript and Python.

#### Standby mode (instant HTTP endpoint)

Standby keeps the model loaded, so requests skip the container start. Send the same fields as the Actor input, either as GET query parameters or as a POST JSON body. The response is `{ "count": n, "items": [...] }`.

```bash
## GET: arrays are comma-separated
curl "https://freecamp008--background-remover.apify.actor/?token=YOUR_APIFY_TOKEN&imageUrls=https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/portrait-of-woman_small.jpg&model=u2netp"

## POST: also return the cutout as base64 in the response
curl -X POST "https://freecamp008--background-remover.apify.actor/?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/portrait-of-woman_small.jpg"], "returnBase64": true}'
```

With `returnBase64: true` (Standby only), each item also contains `imageBase64`, `contentType` and, if `returnMask` is on, `maskBase64`. In Standby you can also send small images inline as `data:image/...;base64,...` URLs.

**AI agents can pay per call:** because the Actor uses pay-per-event pricing and only default storages, AI agents can call it and pay per request with **x402** through Apify. No Apify account setup is needed on the agent side.

### Input example

```json
{
  "imageUrls": [
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/portrait-of-woman_small.jpg"
  ],
  "model": "isnet-general-use",
  "outputFormat": "png",
  "backgroundColor": "",
  "cropToSubject": false,
  "returnMask": false,
  "maskThreshold": 0,
  "featherPx": 0,
  "maxSidePx": 4096
}
```

| Field | Description |
|---|---|
| `imageUrls` | Image links. One result per image. |
| `model` | `isnet-general-use` (default, best), `u2netp` (fastest), `u2net`, `silueta`, `u2net_human_seg` (people). |
| `outputFormat` | `png` or `webp`. |
| `backgroundColor` | Optional hex color such as `#ffffff`. If empty, the background is transparent. |
| `cropToSubject` | Trim the empty margins around the subject. |
| `returnMask` | Also save the grayscale mask (`maskUrl`). |
| `maskThreshold` | 0 keeps soft edges. 1-254 makes a hard cutout at that mask level. |
| `featherPx` | Blur the mask edge by N pixels. |
| `maxSidePx` | Downscale larger images to this size (default 4096). |
| `returnBase64` | Standby API only: include the image as base64 in the HTTP response. |

### Output example

```json
{
  "imageUrl": "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/portrait-of-woman_small.jpg",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/STORE_ID/records/71739f71758474e1-cutout.png",
  "width": 360,
  "height": 450,
  "originalWidth": 360,
  "originalHeight": 450,
  "model": "isnet-general-use",
  "outputFormat": "png",
  "backgroundColor": null,
  "cropBox": null,
  "foregroundRatio": 0.5451,
  "outputBytes": 179413,
  "inferenceMs": 1194,
  "processingMs": 1392
}
```

- `outputUrl`: public link to the cutout (PNG/WebP) in the run's key-value store.
- `maskUrl`: link to the mask PNG (only when `returnMask` is on).
- `foregroundRatio`: share of the image covered by the subject, from 0 to 1. Values near 0 mean nothing was detected.
- `cropBox`: the crop rectangle when `cropToSubject` is on.
- `processingMs`: time to decode, segment, encode and store the image, excluding the download.
- Failed images produce `{ "imageUrl": "...", "error": "...", "isError": true }` and are **not charged**.

### Pricing

This Actor uses **pay-per-event** pricing. You pay only for images that were processed successfully:

| Event | Price | Per 1,000 |
|---|---|---|
| `image-processed`: one background removed and saved | $0.009 | **$9.00** |

Hosted background-removal APIs typically charge **$0.01 to $0.05 per image**. Apify platform usage (compute units, storage) is billed separately according to your Apify plan. Use **Maximum cost per run** to cap spending; the Actor stops cleanly when the limit is reached.

### FAQ

**Which model should I use?**
Start with `isnet-general-use`. It gives the most detailed edges (hair, fur) on products, people, animals and objects. Use `u2netp` when speed matters most: it is roughly 5-7x faster with slightly softer edges. `u2net_human_seg` gives very clean silhouettes for portraits but ignores objects that are not people. `u2net` and `silueta` are classic general-purpose alternatives.

**How fast is it?**
Most of the time goes into the model. With `isnet-general-use` expect a few seconds per image at the default 2 GB memory; `u2netp` takes well under a second. More memory also means more CPU on Apify, so 4-8 GB runs are faster. Standby mode removes the container start time.

**What are the limits?**
Downloads are capped at 50 MB per image, and images are downscaled to `maxSidePx` (default 4096 px, max 8192). Animated GIFs use only the first frame. The default 2 GB memory handles 4K images; 1 GB is the minimum.

**Does it work on any image or language?**
Yes. Background removal does not depend on text or language, and any common image format works. It works best when there is one clear foreground subject. Scenes with many overlapping objects, glass, smoke or very fine transparent details may need manual touch-up.

**Are my images private?**
Yes. Images are processed inside your own Apify run by models bundled with the Actor and are not sent to any external AI service. Results are stored in the run's key-value store. The `outputUrl` links are unguessable but public, so anyone with the link can open the file. Delete the storage or set a data retention period if you need to.

**Can I use the results commercially?**
Yes. The models are released under permissive open-source licenses (Apache-2.0 / MIT) that allow commercial use. You still need the rights to the images you process.

**Is it legal to remove backgrounds from images?**
Editing images you own or are licensed to use is legal. Do not use the Actor to strip watermarks or to reuse copyrighted photos without permission. You are responsible for the images you submit.

**Why is some background left around the edges?**
Soft edges keep fine detail such as hair. If you see a faint halo, set `maskThreshold` (e.g. `128`) for a hard edge, optionally with `featherPx: 1-2` to smooth it, or try a different model.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct links to images (JPEG, PNG, WebP, AVIF, GIF, TIFF). Each image becomes one result with a link to the transparent cutout.

## `model` (type: `string`):

<b>isnet-general-use</b>: best general quality (products, people, animals, objects). <b>u2netp</b>: fastest, lighter quality. <b>u2net</b>: classic general model. <b>silueta</b>: compact U2-Net variant. <b>u2net_human_seg</b>: tuned for people / portraits. Models other than isnet-general-use and u2netp are downloaded on first use (adds a few seconds once per run).

## `outputFormat` (type: `string`):

PNG (lossless, widest support) or WebP (much smaller files, keeps transparency).

## `backgroundColor` (type: `string`):

Hex color like <code>#ffffff</code> or <code>#00ff00</code>. When set, the cutout is placed on this solid color instead of a transparent background (e.g. white product photos for marketplaces).

## `cropToSubject` (type: `boolean`):

Trim the empty area around the subject so the output is tightly cropped.

## `returnMask` (type: `boolean`):

Also save the grayscale segmentation mask (white = subject) and return its URL as <code>maskUrl</code>.

## `maskThreshold` (type: `integer`):

0 keeps the model's soft edges (recommended). 1-254 turns the mask into a hard cutout: pixels with mask value at or above the threshold become fully opaque, the rest fully transparent. Useful to remove faint halos; combine with feathering for clean but soft edges.

## `featherPx` (type: `integer`):

Blur the mask edge by this many pixels (0 = off). Softens jagged edges, especially after a hard threshold.

## `maxSidePx` (type: `integer`):

Images larger than this on their longest side are downscaled first (keeps memory and time predictable). Output size equals the (downscaled) input size.

## `returnBase64` (type: `boolean`):

Standby HTTP API only: also include the output image (and mask) as base64 strings in the response (<code>imageBase64</code>, <code>maskBase64</code>). Ignored in normal runs, where only the URLs are stored.

## Actor input object example

```json
{
  "imageUrls": [
    "https://gratisography.com/wp-content/uploads/2024/11/gratisography-augmented-reality-800x525.jpg"
  ],
  "model": "isnet-general-use",
  "outputFormat": "png",
  "backgroundColor": "#ffffff",
  "cropToSubject": false,
  "returnMask": false,
  "maskThreshold": 0,
  "featherPx": 0,
  "maxSidePx": 4096,
  "returnBase64": false
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrls": [
        "https://gratisography.com/wp-content/uploads/2024/11/gratisography-augmented-reality-800x525.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("freecamp008/background-remover").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrls": ["https://gratisography.com/wp-content/uploads/2024/11/gratisography-augmented-reality-800x525.jpg"] }

# Run the Actor and wait for it to finish
run = client.actor("freecamp008/background-remover").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrls": [
    "https://gratisography.com/wp-content/uploads/2024/11/gratisography-augmented-reality-800x525.jpg"
  ]
}' |
apify call freecamp008/background-remover --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,freecamp008/background-remover"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/1LCgQNwjmrY2DaqMh/builds/UA6wda9HH8b2clLng/openapi.json
