Shopify themes look their best when every product photo shares the same background, framing, and aspect ratio. Mixed backgrounds make collection pages look cluttered and lower trust. A background removal API lets you standardize the whole catalog in one pass and keep new products consistent.

What a consistent Shopify catalog needs

  • Same aspect ratio: square images are the safest default for most themes. Shopify recommends 2048 × 2048 px for square product images.
  • Same background: white or a light brand color across every product.
  • Same framing: products centered with similar padding so grid rows line up.
  • Reasonable file size: large PNGs slow down collection pages, so export the final image as JPEG or WebP when you do not need transparency.

The workflow

  1. Export product images from Shopify (via the Admin API or a product CSV export, which includes image URLs).
  2. Send each image to the background removal API and store the transparent PNG.
  3. Composite the cutout onto your chosen background at 2048 × 2048.
  4. Upload the new image back to the product and keep the original for reference.

Processing an image from its Shopify URL

import io

import requests
from PIL import Image

SIZE = 2048
BACKGROUND = (248, 246, 242)  # light brand color


def standardize(image_url: str, output_path: str) -> None:
    original = requests.get(image_url, timeout=30)
    original.raise_for_status()

    response = requests.post(
        "https://fapihub.com/v2/rembg/",
        headers={"ApiKey": "YOUR_API_KEY"},
        files={"image": ("product.jpg", original.content)},
        timeout=60,
    )
    response.raise_for_status()

    cutout = Image.open(io.BytesIO(response.content)).convert("RGBA")
    cutout = cutout.crop(cutout.getbbox())
    cutout.thumbnail((int(SIZE * 0.82), int(SIZE * 0.82)), Image.LANCZOS)

    canvas = Image.new("RGB", (SIZE, SIZE), BACKGROUND)
    canvas.paste(cutout, ((SIZE - cutout.width) // 2, (SIZE - cutout.height) // 2), cutout)
    canvas.save(output_path, "JPEG", quality=90)

Using the same fill ratio for every product keeps the grid tidy. Adjust it per collection if you sell items with very different shapes, such as tall bottles next to flat accessories.

Keep new products consistent

A one-off cleanup is only half the job. Subscribe to Shopify's products/create webhook and run the same function for each new image. Your team can upload phone photos and the store still looks professionally shot.

Add depth with shadows

Products floating on a flat background can look pasted on. A soft drop shadow grounds them. The /v2/rembg/shadow/ endpoint adds one in the same request. See our product shadow guide for settings that look natural.

What it costs

A store with 2,000 products and three images each needs 6,000 requests for a full cleanup, which fits within the $15 Pro plan. Smaller stores can start on the free plan's 100 requests per month. For the rest of the e-commerce pipeline, read our product image automation guide.

Run the cleanup across the whole catalog

The standardize function above processes one image. For a full cleanup, read the product CSV export, skip images you have already handled, and record failures so you can retry them later. Check the header row of your export for the exact name of the image URL column.

import csv
import hashlib
from pathlib import Path

import requests

IMAGE_COLUMN = "Image Src"  # confirm against your export's header row
OUTPUT = Path("standardized")
OUTPUT.mkdir(exist_ok=True)

failures = []
seen = set()

with open("products_export.csv", newline="", encoding="utf-8") as export:
    for row in csv.DictReader(export):
        url = (row.get(IMAGE_COLUMN) or "").strip()
        if not url or url in seen:
            continue
        seen.add(url)

        name = hashlib.sha1(url.encode()).hexdigest()[:16] + ".jpg"
        target = OUTPUT / name
        if target.exists():
            continue

        try:
            standardize(url, str(target))
        except requests.HTTPError as error:
            failures.append((row.get("Handle"), url, error.response.status_code))

for handle, url, status in failures:
    print(f"{status} {handle} {url}")

Hashing the source URL gives each output a stable file name, so the script is safe to re-run after an interruption. Keep a mapping from product handle to output file so the upload step knows where each image belongs. For larger catalogs, add a small worker pool and Retry-After handling as described in our bulk processing guide.

Choose a background that fits your theme

BackgroundWorks well whenHow to produce it
Pure whiteYour theme uses white product cards and you also sell on marketplaces./v2/rembg/color/ with bgcolor="(255, 255, 255, 255)", or composite locally.
Light brand colorYou want a recognizable look across collection pages.Composite locally, as in the standardize function.
Subtle gradientProducts look flat on a single color./v2/rembg/gradient/ with top_color and bottom_color.
Transparent PNGYour theme places products on colored or changing section backgrounds.Use the /v2/rembg/ output directly, accepting the larger file size.

Pick one and apply it everywhere. A catalog where half the products sit on white and half on beige looks worse than one that uses either consistently. For the trade-offs, see transparent vs. white backgrounds and our guide to changing image background colors.

Webhook pitfalls to avoid

Automating new products with webhooks is where most Shopify integrations go wrong. Plan for these from the start:

  • Respond quickly: acknowledge the webhook right away and process the image in a background job. Shopify expects a fast response and may retry deliveries that take too long.
  • Verify the signature: check the webhook HMAC header with your app secret before trusting the payload.
  • Avoid loops: uploading a processed image updates the product, which can trigger update webhooks. Record which image IDs or source hashes you have already processed and skip them.
  • Expect duplicates: the same webhook can be delivered more than once. Make the job idempotent so a repeat does not spend another request.

Roll it out safely

  1. Process one collection first and compare it with the live store on desktop and mobile.
  2. Review edges on products with fine detail, such as hair accessories, fabric fringe, or glassware. Try the falcon, aurora, and ghost models on any that look wrong and keep the best result.
  3. Keep the original images, either attached to the product or in your own storage, so you can revert.
  4. Preserve alt text when you replace images. Losing it hurts accessibility and search.
  5. Roll out the remaining collections once the first one looks right.

Budget for ongoing uploads

After the initial cleanup, volume depends on how often you add products. A store adding 50 products a month with three images each needs about 150 requests per month, slightly more than the free plan's 100. A $10 Per Usage purchase of 1,000 requests covers roughly six months of that, and the requests never expire. Stores that add hundreds of products a month are better served by a monthly plan; see the e-commerce use case and pricing.

Frequently asked questions

Do I need a Shopify app to use this?

No. A script run against your product CSV export is enough for a one-off cleanup. Ongoing automation with webhooks requires a custom app or a small backend that can receive Shopify webhooks and call the Admin API.

Should I upload JPEG, WebP, or PNG to Shopify?

Use JPEG or WebP for product images on a solid background, since they are much smaller than PNG. Upload PNG only when you need transparency, for example when your theme shows products over colored sections.

Will replacing images affect my product pages?

The product stays the same, but you are swapping the media attached to it. Keep the same image order and alt text, and test on one collection first so you can compare before rolling out.

Can I use the same images on Amazon or other marketplaces?

Yes, if you keep the transparent PNG as your master asset. Generate a white version for marketplaces and a branded version for Shopify from the same cutout. Our Amazon white background guide shows how.