DEV Community

Cover image for Can AI Make Transparent PNGs? Gemini, ChatGPT, Grok
AI Engine
AI Engine

Posted on Originally published at ai-engine.net

Can AI Make Transparent PNGs? Gemini, ChatGPT, Grok

You asked an image generator for a logo, a sticker or a product mockup "on a transparent background", downloaded the PNG, dropped it on your site, and got a white box or a grey checkerboard around it. Most AI image tools cannot output a real alpha channel, and the ones that try often paint the checkerboard into the pixels.

Here is the answer tool by tool, a way to check whether a file is really transparent, and a Python fix that turns any AI-generated image into a true transparent PNG.

Want to test it on your own generated images? Try the Background Removal API on one of them.

Which AI Image Generators Support Transparency?

Based on each tool's official documentation, checked in October 2026:

  • Gemini / nano banana: no documented transparency option. You get a solid background, or a checkerboard drawn into the image.
  • OpenAI GPT Image API: yes, on supported models. Set background to transparent with PNG or WebP output.
  • Grok (xAI): no documented option. Treat every image as opaque.
  • Midjourney: no parameter for it in the full parameter list. Prompt a plain background and remove it afterwards.

On the Google AI developer forum, users asking how to get a transparent background with Nano Banana Pro describe the same result: the background is "only graphically represented as tiles", not see-through. Typing "transparent background" in the prompt makes it worse, because the model draws the checkerboard it has seen in thousands of screenshots.

The Fake Checkerboard Problem

A painted checkerboard looks right in the preview. The grey and white squares are regular pixels with full opacity, so they show up around your logo on a dark website header. Check a file before it reaches production:

from PIL import Image


def has_real_transparency(path: str) -> bool:
    im = Image.open(path)
    if im.mode not in ("RGBA", "LA", "PA") and "transparency" not in im.info:
        return False  # no alpha channel at all
    # at least one pixel must be less than fully opaque
    return im.convert("RGBA").getchannel("A").getextrema()[0] < 255


print(has_real_transparency("generated.png"))  # False for a painted checkerboard
Enter fullscreen mode Exit fullscreen mode

On the cover image, the left half returns False (plain RGB). The right half returns True: the robot sits on a background that is half checkerboard, half blue, which only works when the pixels around it are truly empty.

The Fix: Plain Background, Then One API Call

Step 1: generate on a plain, contrasting background. Ask for "a plain solid orange background, no shadow, no floor". Avoid the word "transparent" in the prompt, it is what triggers the painted checkerboard.

Step 2: remove the background. Send the file to /remove-background. The response is JSON with a link to an RGBA PNG:

import requests

API_URL = "https://background-removal-ai.p.rapidapi.com/remove-background"
HEADERS = {
    "x-rapidapi-host": "background-removal-ai.p.rapidapi.com",
    "x-rapidapi-key": "YOUR_API_KEY",
}

with open("robot.png", "rb") as f:
    r = requests.post(API_URL, headers=HEADERS, files={"image": f}, timeout=60)
r.raise_for_status()
data = r.json()
print(data["image_url"], data["width"], data["height"])

png = requests.get(data["image_url"], timeout=60).content
with open("robot-transparent.png", "wb") as f:
    f.write(png)
Enter fullscreen mode Exit fullscreen mode

If your generator returns a URL, pass it directly with json={"image_url": "https://example.com/generated.png"} instead of uploading the file.

The render on a solid orange background, the transparent PNG from the API on a checkerboard, and the same robot on a blue brand color

The test image is a 3D character render on a flat orange backdrop, the same kind of output an image generator returns. The cutout keeps the hands, the thin arm joints and the reflective visor. We also sent a recreated checkerboard version: the API removed the painted squares and returned a clean RGBA file.

See the full guide with the tool-by-tool table, cURL example and sources on ai-engine.net.

Batch Script for Stickers and Icons

AI-generated assets come in sets. This script converts a whole folder in parallel (PNG, JPEG and WebP in, transparent PNG out):

import requests
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor

API_URL = "https://background-removal-ai.p.rapidapi.com/remove-background"
HEADERS = {
    "x-rapidapi-host": "background-removal-ai.p.rapidapi.com",
    "x-rapidapi-key": "YOUR_API_KEY",
}
SRC = Path("generated")  # images exported from your AI generator
OUT = Path("transparent")
OUT.mkdir(exist_ok=True)


def make_transparent(path: Path) -> str:
    with open(path, "rb") as f:
        r = requests.post(API_URL, headers=HEADERS, files={"image": f}, timeout=60)
    r.raise_for_status()
    png = requests.get(r.json()["image_url"], timeout=60).content
    out = OUT / f"{path.stem}.png"
    out.write_bytes(png)
    return out.name


files = sorted(p for p in SRC.iterdir() if p.suffix.lower() in {".png", ".jpg", ".jpeg", ".webp"})
with ThreadPoolExecutor(max_workers=4) as pool:
    for name in pool.map(make_transparent, files):
        print("saved", name)
Enter fullscreen mode Exit fullscreen mode

Four 3D renders on solid backgrounds and the four transparent PNG stickers produced by the batch script

Chroma Key or an API?

If you control the prompt, you can generate on pure green and delete green pixels with a color mask. It is free, and it breaks on:

  • Green or yellow-green subjects (plants, mascots, neon logos)
  • Soft edges like hair, fur and smoke, which keep a green fringe
  • Reflections and glass that pick up the green cast
  • Images you did not generate: user uploads, painted checkerboards, old asset libraries

A segmentation-based API looks at the subject, not at a color, so one call handles all of these.

Tips for Clean Cutouts

  • Ask for contrast, not transparency. Dark subject on a light flat color, or the reverse.
  • Ban shadows and floors in the prompt. A soft drop shadow is part of the image.
  • Generate at full size. Upscale before the cutout, not after.
  • Need a brand color instead? The /color-background endpoint takes bg_color as "R,G,B,A" (for example "37,99,235,255") and returns the subject on your exact color.

Sources

Ready to fix your generated assets? Get a key for the Background Removal API, point the batch script at your folder and run it. Read the full guide on ai-engine.net.

Top comments (0)