Skip to main content

Automatically replace and relight the background of any image using APImage

Workflow preview

Workflow preview
100%
Automatically replace and relight the background of any image using APImage preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow takes an image URL and a description of the desired background, then uses the APImage AI API to produce a high quality image, preserving the subject and applying a natural looking new...

Best for

  • Content Creation automation workflows
  • Multimodal AI automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.httprequest, n8n-nodes-base.formtrigger, n8n-nodes-base.googledrive

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Gegenfeld.

Original n8n.io source

1.1 Workflow description

Title
Automatically replace and relight the background of any image using APImage
Workflow name
Automatically replace and relight the background of any image using APImage

This workflow takes an image URL and a description of the desired background, then uses the APImage AI API to produce a high-quality image, preserving the subject and applying a natural-looking new background.

Example Result

Here you can see a before-and-after image, generated by APImage, using this workflow.


Who This Workflow is For

This workflow is perfect for anyone looking to generate polished, professional images quickly:

  • E-commerce Teams: Ensure consistent product images with uniform, professional backdrops to reinforce brand identity and trust.
  • Content Creators: Generate eye-catching visuals for social media, blogs, or marketing campaigns quickly.
  • Designers: Produce realistic mockups and conceptual designs without hours of manual editing.
  • Businesses of All Sizes: Automate large-scale image pipelines efficiently without expanding staff or budget.
  • Anyone Needing AI Imaging: Personal or professional projects can benefit from this automated, high-quality workflow.

How the Workflow Works

This n8n workflow leverages a Form Trigger and APImage’s AI endpoint to automate background replacement:

       ┌───────────────┐
       │   Input Image │
       │ (URL / source)│
       └───────┬───────┘
               │
               ▼
       ┌──────────────────────────┐
       │  Background Replacement  │
       │   + Lighting Optimization│
       │      (APImage AI)        │
       └───────┬──────────────────┘
               │
               ▼
       ┌──────────────────────┐
       │   Download Image     │
       │ (default name: data) │
       └───────┬──────────────┘
               │
               ▼
       ┌───────────────────────────┐
       │        Output Nodes        │
       │  (DBs, Cloud, CMS, APIs)  │
       └───────────────────────────┘

  • Form Trigger: Collects the image URL and descriptive prompt. Can be swapped with any data source node (databases, cloud storage, APIs).

  • APImage Integration: Processes the image, separates the subject, generates the new background, and preserves realistic lighting and shadows.

  • Download Node: Retrieves the processed image for storage or further use.

  • Output Options: Automatically upload images to Google Drive, Dropbox, Airtable, Notion, Amazon S3, or any other database, creating a fully automated pipeline.

How to Set Up the Workflow

  1. Add Your APImage API Key

  2. Open the APImage API node.

  3. Replace Bearer YOUR_API_KEY with your API key from the APImage Dashboard 🡥.

Test the Workflow

  1. Enter a valid image URL and a descriptive prompt in the Replace Background form.

  2. Click Run Workflow to see the processed image downloaded locally.

  3. Optional: Customize Output Storage

  4. Add nodes after the Download step to automatically save images to your preferred storage service or database.

Requirements

  • n8n instance: Cloud or self-hosted instance.

  • APImage account and API key: Required to access the AI API.

How to Customize the Workflow

  • Change Background Prompts: Modify the form or connect to dynamic sources like databases, CMS, or cloud storage.

  • Adjust AI Settings: Customize preserve_subject, light_direction, and light_strength in the APImage node for perfect results.

  • Extend Outputs: Connect to additional platforms for automatic sharing with teams, clients, or CMS systems.

  • Automate Input: Replace manual form triggers with automated triggers from Google Sheets, Airtable, Shopify, or product databases to handle bulk processing without manual intervention.

Example Use Cases

  • E-commerce: Consistent product images with professional backgrounds.

  • Marketing & Social Media: Quickly generate visuals adapted to multiple themes.

  • Photography & Design: Produce mockups, portraits, and conceptual images with realistic lighting.

  • Business Automation: Scale image pipelines efficiently for large volumes.

FAQ

Q: What types of images are supported? A: JPG, PNG, and WebP are supported.

Q: Can I choose a custom background? A: Yes. Provide a text description or integrate with other nodes supplying pre-defined backgrounds.

Q: What is the default filename for processed images? A: The default filename is data, unless renamed in the workflow.

Q: Do I need to store images locally? A: No. Connect output nodes to databases, cloud storage, or CMS platforms to store images automatically.

Q: Can APImage be used in automated workflows? A: Absolutely. Integrate with n8n to process images automatically from various sources.

Q: Does it enhance image quality? A: APImage adjusts lighting and contrast for natural, realistic results.

Q: How is background replacement different from background removal? A: Background removal makes the background transparent. Background replacement swaps it with a new one and adjusts lighting for a natural look.

Q: Are there limits to the number of images processed? A: Limits depend on your subscription plan and allocated credits

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Download Image

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 5 - APImage API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 6 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Replace Background (node can be exchanged)

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.2

Block 10 - Store the output image (node can be exchanged)

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

3. Summary Table

Workflow Automatically replace and relight the background of any image using APImage
Complexity intermediate
Nodes 10
Categories Content Creation, Multimodal AI
Author Gegenfeld
Published 15 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8619/8619.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automatically replace and relight the background of any image using APImage do?

This workflow takes an image URL and a description of the desired background, then uses the APImage AI API to produce a high quality image, preserving the subject and applying a natural looking new...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Content Creation, Multimodal AI use case.