JUHE API Marketplace

Bulk Background Removal with Nano Banana (Gemini 2.5 Flash)

3 min read
By Chloe Anderson

Nano Banana (Gemini 2.5 Flash Image) is equally powerful as a utility tool for Background Removal.

This workflow demonstrates how to process thousands of product images automatically, stripping away backgrounds with high precision using Gemini's multimodal capabilities, at a fraction of the cost of dedicated background removal APIs.

Why use Gemini for Background Removal?

  1. Cost: Gemini 2.5 Flash is significantly cheaper than services like remove.bg or PhotoRoom API for high volumes. API cost is around $0.015 per image.
  2. Context Awareness: Unlike standard segmentation models, Gemini understands the object you are trying to keep using natural language prompts (e.g., "Keep the watch, remove the stand").
  3. Speed: It is optimized for low latency, making batch processing viable. 10 seconds per image.

The Workflow Architecture

We have built a dedicated "Batch Background Remover" workflow using n8n.

Step 1: Input Source (Google Drive)

  • The workflow monitors a specific Google Drive Input Folder.
  • It automatically lists all image files in that folder.
  • Scalability: Drop 100 raw studio shots in the folder, and the automation queues them all.

Step 2: The Loop

The workflow iterates through each image:

  1. Download: Fetches the raw image.
  2. Base64 Conversion: Prepares the binary data for the Gemini API.
  3. API Request: Sends the image with a precise removal prompt.

The Removal Prompt

The key difference from the Ad Creative workflow is the prompt instructions:

json
{
  "contents": [{
    "parts": [
      { "text": "Remove the background from this image. The output should be the main subject of the image on a purely transparent background. Ensure edges are clean and precise." },
      {
        "inline_data": {
          "mime_type": "image/png",
          "data": "{{ $node['Convert to Base64'].json.data }}"
        }
      }
    ]
  }]
}

Step 3: Output Processing

  • The model returns the isolated subject on a transparent layer (PNG).
  • The workflow saves the result to a designated Output Folder.
  • It appends _nobg to the original filename (e.g., shoe_1.jpg -> shoe_1_nobg.png).

How to Use This Workflow

Prerequisites

  1. n8n: A self-hosted instance or n8n cloud account.
  2. Google Cloud Project: Enabled "Generative Language API" (Gemini).
  3. Google Drive API: Enabled credentials.

Setup Instructions

  1. Import the Workflow: Download the JSON file below and import it into n8n.
  2. Configure Credentials:
    • Set up your Google Drive credentials.
    • Set up your Wisdom Gate API key.
  3. Set Folder IDs:
    • Input Folder: Copy the ID of the Drive folder containing your source images into the List Input Images node.
    • Output Folder: Copy the ID of the destination folder into the Upload Result node.
  4. Run: Click "Execute Workflow".

Download Workflow

Contact support@juheapi.com to get the complete JSON workflow file.


Resources: