5 Best Background Removal APIs (with PHP Examples)

Background removal has become a core part of modern image workflows.

From eCommerce product photos to automated media editing, developers now rely on APIs that can isolate subjects using AI while keeping integrations simple.

Below is a curated list of popular services and what they bring to the table.

ShortPixel API

ShortPixel offers background removal as part of its Reducer API, which handles optimization, resizing, conversion, and background removal. You can replace the background with transparency, a solid color, or even a custom image URL.

Key features

  • Option to return transparent, solid color, or custom image backgrounds
  • Works alongside compression and WebP/AVIF generation
  • Supports large batch requests through URL lists
  • Simple JSON-based API and PHP-friendly tooling

PHP example

<?php

$URL = "https://api.shortpixel.com/v2/reducer.php";
$APIKey = "<<YOUR API KEY HERE>>";

$Data = json_encode(array(
    "plugin_version" => "XY123",
    "key" => $APIKey,
    "lossy" => 1,
    "bg_remove" => 1,
    "urllist" => array(
        "https://example.com/image.jpg"
    )
));

$POSTArray = array(
    'http' => array(
        'method'  => 'POST',
        'header'  => "Content-Type: application/json\r\nAccept: application/json\r\nContent-Length: " . strlen($Data),
        'content' => $Data
    )
);

$Context = stream_context_create($POSTArray);
$Result  = file_get_contents($URL, false, $Context);

echo $Result;

?>

remove.bg

remove.bg is one of the most widely used APIs for automated background removal. It’s built around a straightforward POST request and supports uploads, URLs, and base64 input. The service handles up to 50-megapixel images and returns cutouts in formats like PNG, JPG, WebP, or ZIP for high-performance workflows.

Key features

  • Accepts file uploads, URLs, or base64
  • Output up to 50 MP, depending on format
  • Supports PNG, JPG, WebP, and ZIP (fastest option with separate color and alpha channels)
  • Optional extras like cropping, shadows, region of interest, and background replacement
  • Clear rate-limit rules and credit headers for tracking usage

PHP example

<?php

require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

$response = $client->post('https://api.remove.bg/v1.0/removebg', [
    'multipart' => [
        [
            'name'     => 'image_file',
            'contents' => fopen('/path/to/image.jpg', 'r')
        ],
        [
            'name'     => 'size',
            'contents' => 'auto'
        ],
        [
            'name'     => 'format',
            'contents' => 'png'
        ]
    ],
    'headers' => [
        'X-Api-Key' => 'YOUR_API_KEY'
    ]
]);

file_put_contents('no-bg.png', $response->getBody());

Adobe Photoshop API (Background Removal)

Adobe’s cloud-based Photoshop API brings some of the same Sensei-powered features from desktop Photoshop into a REST workflow. One of the most popular endpoints is the background-removal service, which generates high-quality masks for product images, marketing assets, and automated creative pipelines.

Key features

  • High-accuracy cutouts powered by Adobe Sensei
  • Soft or binary mask output
  • Works with cloud storage locations you define
  • Fits into automated marketing, e-commerce, and batch-processing flows

Adobe doesn’t ship a PHP SDK, but you can call the API normally with any HTTP client (Guzzle works well)

PHP example

<?php

require 'vendor/autoload.php';

$client    = new GuzzleHttp\Client();
$apiKey    = 'YOUR_API_KEY';
$token     = 'YOUR_OAUTH_TOKEN';

// Adobe requires referencing images through cloud storage.
// These values should point to your storage provider and file URLs.
$inputHref  = 'https://your-storage/input.jpg';
$outputHref = 'https://your-storage/output-mask.png';

$payload = [
    'input' => [
        'storage' => 'external',   // or adobe depending on setup
        'href'    => $inputHref
    ],
    'output' => [
        'storage' => 'external',
        'href'    => $outputHref,
        'mask'    => [
            'format' => 'soft'    // or binary
        ]
    ]
];

$response = $client->post(
    'https://image.adobe.io/sensei/mask',
    [
        'headers' => [
            'x-api-key'      => $apiKey,
            'Authorization'  => 'Bearer ' . $token,
            'Content-Type'   => 'application/json'
        ],
        'body' => json_encode($payload)
    ]
);

echo $response->getBody();

Cloudinary Background Removal Add-on (via Remove.bg or AI models)

Cloudinary integrates background removal as an add-on service. Developers can run transformations directly through URL parameters or server-side calls.

Key features

  • On-the-fly background removal using a single transformation
  • Optional fine-edge mode for subjects with detailed edges
  • Combine with any other transformation such as resize, grayscale or underlays
  • Fast delivery through Cloudinary’s CDN
  • PHP SDK with simple method chaining for transformations

PHP example

This example uses Cloudinary’s PHP SDK and applies the background_removal effect when generating a delivery URL. The original stays intact, and the derived result gets cached automatically.

<?php

use Cloudinary\Cloudinary;
use Cloudinary\Transformation\Effect;
use Cloudinary\Transformation\Image;

// Init Cloudinary
$cloudinary = new Cloudinary([
    'cloud' => [
        'cloud_name' => 'your_cloud_name',
        'api_key'    => 'your_api_key',
        'api_secret' => 'your_api_secret',
    ]
]);

// Create a transformed image URL with background removed
$url = $cloudinary->image("samples/dog_couch.jpg")
    ->effect(Effect::backgroundRemoval())
    ->toUrl();

echo $url;

Pixelcut API

Pixelcut offers a fast, AI-driven background-removal API built for production workflows. It’s tuned for accurate edge detection and handles high-resolution images without slowing down. Since it powers the Pixelcut app used by millions, the API is stable enough for e-commerce pipelines, creative tools, and automated content generation.

Key features

  • Sharp edge detection, even around hair, fur and transparent objects
  • Supports large images up to six thousand pixels
  • Accepts JPG or PNG and returns clean transparent PNGs or alpha masks
  • Quick processing with no image retention after completion
  • Simple JSON request format that’s easy to integrate into any PHP workflow

PHP example

Pixelcut expects a JSON request containing the image location and desired output format. Here’s a PHP example using standard cURL:

<?php

$apiKey   = 'YOUR_API_KEY';
$imageUrl = 'https://cdn3.pixelcut.app/product.jpg';

$payload = json_encode([
    'image_url' => $imageUrl,
    'format'    => 'png'   // transparent PNG output
]);

$ch = curl_init('https://api.developer.pixelcut.ai/v1/remove-background');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        'Accept: application/json',
        'X-API-KEY: ' . $apiKey
    ],
    CURLOPT_POSTFIELDS     => $payload
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Andrei Alba
Andrei Alba

Andrei Alba is a support specialist and writer here at ShortPixel. He enjoys helping people understand WordPress through his easily digestible materials.

Articles: 80