# Background Remover: transparent PNG cutouts in bulk (`examsens.ai/background-remover`) Actor

Removes the background from every image URL you list with BiRefNet, running inside the actor with no outside API. Transparent PNG or WebP at full resolution, or any solid background color, with optional crop to the subject and a black and white mask.

- **URL**: https://apify.com/examsens.ai/background-remover.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** AI, For creators
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 background removeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Background Remover: transparent PNG cutouts in bulk

Give it a list of image URLs and it cuts the subject out of each one with BiRefNet, an open segmentation model. The model runs inside the actor, so your images go to no outside API and there is no key to set up. You get a transparent PNG or WebP at the full size of the original, or the subject placed on any solid color.

### What it does

- Removes the background from photos and keeps the subject at the original resolution.
- Transparent or colored background. Leave the color empty for transparency, or set one such as `#ffffff`, `white` or `#0000ff80` (half transparent blue).
- Cleans edge colors. The old background's color is taken out of hair, fur and other soft edges. On a photo of a black puppy on a gray wooden deck, the soft edge pixels averaged a brightness of 62 without this step and 11 with it.
- Crops to the subject if you ask, with a margin you choose.
- Saves the mask if you ask: a black and white PNG where white is the subject, for your own compositing.
- Turns photos upright from their EXIF orientation first, so portrait photos stay portrait.
- Handles many images in one run. Each image gets its own result, and one bad link never stops the run.

Reads JPEG, PNG, WebP, GIF, BMP, TIFF and the other formats Pillow reads. A PNG that already has transparency keeps its transparent areas. An animated GIF is processed from its first frame, and the item says so in `note`. When the model finds no subject, such as on a plain gray image, the item says so in `note`.

### Input

- Image URLs (required)
- Output format: PNG (default), WebP or JPEG. JPEG has no transparency, so it always gets a background color, white unless you set one.
- Background color (default empty, for transparency)
- Clean edge colors (default on)
- Crop to subject (default off) and crop margin in pixels (default 0)
- Also save the mask (default off)
- Quality (default 90), for JPEG and WebP
- Largest source image in megapixels (default 16, ceiling 25). A larger source gets an error item and is not charged.
- Maximum file size in MB (default 25)

### Output

Dataset: one item per URL with `outputUrl` (download link), `outputKey`, `outputFormat`, `outputWidth`, `outputHeight`, `transparent`, `foregroundPercent` (the share of the image that is subject), `cropBox` when cropped, `maskUrl` and `maskKey` when the mask is saved, `inputWidth`, `inputHeight`, `outputBytes` and `processingSeconds`. Files are named by their position in your list and the source file name, such as `0001-photo-cutout.png` and `0001-photo-mask.png`.

A URL that cannot be processed gets `ok: false` and an `error`, such as `HTTP 404`, an unknown host, a file over the size limit, a source over the megapixel limit, or "the file is not an image format this actor can read" for a web page.

### Speed

The model runs on the CPU at 1024 by 1024 whatever the source size, and the mask is then scaled to the full image. At the default 4 GB of memory, an 800 by 600 photo took 14 seconds and a 4000 by 4000 photo took 25 seconds.

### Model and license

BiRefNet lite, by Peng Zheng and coauthors, released under the MIT License. The edge color cleanup uses blur fusion foreground estimation, as in the BiRefNet code.

### Pricing

Pay per event: one event per image processed. URLs that fail are not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Only the URLs you supply are downloaded. The actor does not log in anywhere and uses no proxies. Process images you have the right to use.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

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

Direct links to image files (JPEG, PNG, WebP, GIF, BMP, TIFF and other formats Pillow reads).

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

PNG and WebP keep transparency. JPEG has none, so it always gets a background color (white unless you set one).

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

Leave empty for a transparent background. Or a CSS color such as #ffffff, white or #00000080 to place the subject on a solid color.

## `refineEdges` (type: `boolean`):

Removes the old background's color from hair, fur and other soft edges.

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

Trim the empty area around the subject.

## `cropMargin` (type: `integer`):

Space to keep around the subject when cropping.

## `outputMask` (type: `boolean`):

Save a black and white PNG mask next to each cutout: white is the subject, black is the background.

## `quality` (type: `integer`):

1 to 100 for JPEG and WebP. PNG ignores this.

## `maxInputMegapixels` (type: `number`):

Source images with more pixels than this get an error item and are not charged. The ceiling is 25.

## `maxFileSizeMb` (type: `integer`):

Skip source files larger than this, with an error item.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://picsum.photos/id/237/800/600"
    }
  ],
  "outputFormat": "png",
  "refineEdges": true,
  "cropToSubject": false,
  "cropMargin": 0,
  "outputMask": false,
  "quality": 90,
  "maxInputMegapixels": 16,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `results` (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": [
        {
            "url": "https://picsum.photos/id/237/800/600"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/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": [{ "url": "https://picsum.photos/id/237/800/600" }] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/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": [
    {
      "url": "https://picsum.photos/id/237/800/600"
    }
  ]
}' |
apify call examsens.ai/background-remover --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/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/efroxz5RbI1t6goyr/builds/t7gakwt3tgUGEYyyX/openapi.json
