# GIMP 3 Plugin for Background Removal

Remove image backgrounds inside **GIMP 3.0** using a local withoutBG API (Docker service or Mac app). The plugin sends your active layer to the API, fetches an alpha matte, and attaches it as an **unapplied layer mask**. Processing stays on your machine, unless you opt in to withoutBG Pro.

Source: [github.com/withoutbg/withoutbg-gimp](https://github.com/withoutbg/withoutbg-gimp) · [withoutBG for Mac](/mac) · [Docker docs](/docs/open-model/docker)

![GIMP with a withoutBG transparent cutout](/images/mac/gimp-local-api.png)

## Install command

```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/withoutbg/withoutbg-gimp/main/install.sh)"
```

Installs the plugin into your GIMP 3.0 plug-ins directory. Restart GIMP after.

## Requirements

| Dependency | Notes |
|---|---|
| [GIMP 3.0](https://www.gimp.org) | GIMP 2.x is not supported |
| Local withoutBG API | Must be running before you invoke the plugin (see below) |

## Start a local API

The plugin talks to a withoutBG HTTP API on `127.0.0.1`. Pick one backend:

### Docker service (port 8000)

Cross-platform. Uses the open weights v4 ONNX model from [withoutbg-inference](https://github.com/withoutbg/withoutbg-inference).

```bash
docker run --rm -p 8000:8000 withoutbg/withoutbg-openweights-v4-service-cpu:latest
```

Server URL for the plugin: `http://127.0.0.1:8000`

Full Docker docs: [/docs/open-model/docker](/docs/open-model/docker)

### Mac app Local API (port 8000)

macOS only. [withoutBG for Mac](/mac) is one app: a desktop batch UI plus an optional Local API in the menu bar. Use the Local API when you want GIMP (or scripts) to call withoutBG on your machine. On Apple Silicon, inference uses Core ML.

1. Install [withoutBG for Mac](/mac) (download from GitHub Releases).
2. Start the Local API from the empty-state **Start Local API** button, or from the menu bar icon. Default URL: `http://127.0.0.1:8000`
3. Confirm the menu bar shows **Local API Running** before using the plugin.

Docker `service-*` and the Mac app Local API both use port **8000** by default, so the plugin works with either backend without changing settings. Run one backend at a time on that port.

The plugin dialog accepts any server URL if you change the port. More detail: [/mac](/mac) · [Local API docs](/docs/open-model/local-api).

### Verify the API

```bash
curl http://127.0.0.1:8000/health
```

Expected response:

```json
{
  "status": "ok",
  "model": "withoutbg-openweights-oss",
  "version": "4.1.0"
}
```

Wait until `/ready` returns `{"status":"ready"}` on first startup (model warmup).

## Install the plugin

```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/withoutbg/withoutbg-gimp/main/install.sh)"
```

Or clone and run locally:

```bash
git clone https://github.com/withoutbg/withoutbg-gimp.git
cd withoutbg-gimp
./install.sh
```

Restart GIMP. The plugin appears under:

```
Tools ▸ WithoutBG ▸ Remove Background…
```

### Manual install paths

| Platform | Plug-ins directory |
|---|---|
| macOS | `~/Library/Application Support/GIMP/3.0/plug-ins/` |
| Linux | `~/.config/GIMP/3.0/plug-ins/` |

Layout after install:

```
plug-ins/withoutbg/withoutbg.py
```

## Usage

1. Open an image in GIMP and select the layer to process.
2. Go to **Tools ▸ WithoutBG ▸ Remove Background…**
3. Check the dialog. It shows server status (model name and version from `/health`).
4. Confirm **Server URL** is `http://127.0.0.1:8000` (default for both Docker and the Mac app Local API).
5. Click **Remove Background**.

The plugin:

1. Exports the active layer as PNG (longest side capped at 1024 px before upload).
2. POSTs to `/v1/remove-background?output=matte` with `Content-Type: image/png`.
3. Upscales the returned matte to full layer resolution.
4. Adds it as an **unapplied layer mask** on the active layer.

To commit the mask: **Layer ▸ Mask ▸ Apply Layer Mask**.

## Fix the mask with Smart Brush

Open **Tools ▸ WithoutBG ▸ Smart Brush…** with the layer selected. The dialog shows the cutout on a checkerboard. Paint **Keep** (green) over what went missing and **Remove** (red) over what should go. Strokes are smoothed, so a rough line is enough. Click **Apply** and the layer mask updates in place (one undo step). Smart Brush starts from the mask as it is, so hand edits are kept.

## Optional: withoutBG Pro

No server running, or you want the hosted model? Tick **Use withoutBG Pro (cloud)** in the dialog and paste a [withoutBG Pro](/pro-model-api) API key (hidden by default; click the eye icon to show it), or set `WITHOUTBG_API_KEY` in the environment GIMP starts from.

With Pro on, the layer (downscaled to 1024 px) is sent to `api.withoutbg.com` and uses 1 credit. The matte still comes back as an unapplied layer mask. GIMP stores the last-used dialog values, the key included, in your GIMP profile. Use the environment variable if you'd rather keep it out of there.

## Server URL

Default in the plugin: `http://127.0.0.1:8000` (same for Docker `service-*` and the Mac app Local API).

| Backend | URL |
|---|---|
| Docker `service-*` | `http://127.0.0.1:8000` |
| Mac app Local API | `http://127.0.0.1:8000` |
| Custom port | `http://127.0.0.1:<port>`, must match Local API settings |

You can override the URL per session in the plugin dialog; GIMP remembers the last value.

To change the baked-in default, edit `SERVER_URL` at the top of `withoutbg/withoutbg.py`.

## API the plugin uses

Both backends expose the same endpoints:

| Endpoint | Purpose |
|---|---|
| `GET /health` | Server status (shown in the dialog) |
| `POST /v1/remove-background?output=matte` | Raw PNG in, grayscale matte PNG out |

The plugin reads the `X-Latency-Ms` response header but does not display it.

## Troubleshooting

| Symptom | Fix |
|---|---|
| "Server not reachable" | Start the Docker service or the Mac app Local API. Confirm `curl http://127.0.0.1:8000/health` (or your port). |
| Server shows ready but inference fails | Model still warming up. Wait for `/ready` to return 200, then retry. |
| Wrong port | Update **Server URL** in the dialog to match your backend (default `8000`). Only one backend should listen on that port at a time. |
| Plugin missing after install | Restart GIMP. Confirm `withoutbg/withoutbg.py` is under the plug-ins directory above. |
| Layer mask looks soft | Expected at mask edges after upscale from 1024 px matte; paint on the mask to refine. |

## Uninstall

```bash
rm -rf ~/Library/Application\ Support/GIMP/3.0/plug-ins/withoutbg   # macOS
rm -rf ~/.config/GIMP/3.0/plug-ins/withoutbg                        # Linux
```

Restart GIMP.

## Common questions

**Does the GIMP plugin upload my images to the cloud?**  
Not by default. The plugin talks to a withoutBG HTTP API on `127.0.0.1` (Docker service or Mac app Local API) and processing stays on your machine. Only if you tick **Use withoutBG Pro (cloud)** and add an API key is the layer (downscaled to 1024 px) sent to api.withoutbg.com.

**Does it work with GIMP 2.x?**  
No. The plugin requires GIMP 3.0. GIMP 2.x is not supported.

**Do I need Docker, or can I use the Mac app?**  
Either works. Run the Docker withoutbg service on port `8000`, or start the Local API from [withoutBG for Mac](/mac). Default Server URL is `http://127.0.0.1:8000` for both.

**What does the plugin add to my layer?**  
An unapplied layer mask built from the grayscale alpha matte. To commit the cutout, use **Layer ▸ Mask ▸ Apply Layer Mask** in GIMP.

**Is Windows supported?**  
The plugin itself targets GIMP 3 on macOS and Linux. On Windows, use the Docker service as the local API backend with GIMP 3 if you run GIMP there.

**Why does the layer mask look soft at the edges?**  
The active layer is capped at 1024 px on the longest side before inference, then the matte is upscaled. Soft edges at the mask boundary are expected; paint on the mask to refine.

## Related

| Resource | Link |
|---|---|
| Krita plugin | [/open-model/plugins/krita](/open-model/plugins/krita) |
| ComfyUI node | [/open-model/plugins/comfyui](/open-model/plugins/comfyui) |
| Docker self-hosting | [/docs/open-model/docker](/docs/open-model/docker) |
| withoutBG for Mac | [/mac](/mac) |
| Local API docs | [/docs/open-model/local-api](/docs/open-model/local-api) |
| Open Model | [/open-model](/open-model) |
| Plugin source | [github.com/withoutbg/withoutbg-gimp](https://github.com/withoutbg/withoutbg-gimp) |
| Inference service source | [github.com/withoutbg/withoutbg-inference](https://github.com/withoutbg/withoutbg-inference) |
