Image Background Replacement and Relighting with APImage - n8n Workflow

Automate image background replacement and relighting using this powerful n8n workflow. Integrate the APImage API to transform product photos or portraits instantly within your n8n environment.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

E-commerce businesses needing automated product photo background changes.
Marketing teams requiring dynamic image content creation and rapid visual asset production.
Developers and technical users looking for advanced AI image processing within an n8n environment.
Anyone building custom n8n templates for visual asset management and automated publishing.

Overview

This expert n8n workflow provides a robust solution for automating visual asset transformation, specifically focusing on changing backgrounds and optimizing lighting using the APImage API. The typical complexity of handling API calls, dynamic URL fetching, and binary file downloads is greatly simplified into a straightforward n8n node sequence. This automation solves the common challenge of manual image editing, saving significant time for users dealing with large volumes of photographs. By leveraging this n8n template, users can quickly integrate high-quality AI image modification into existing business processes, ensuring consistency and professional quality across all visual materials. This particular n8n workflow example is foundational for scaling image operations.

How it Works

The process initiates with the Replace Background n8n trigger node, which collects the source Image URL and the desired Background Description via a simple user form. This n8n trigger node is easily replaceable by any other n8n node that supplies image data, such as a database query or webhook. Next, the core APImage API n8n node executes an HTTP POST request. This request contains crucial parameters—such as the image URL, the textual background prompt, lighting direction (above), and intensity (0.6)—along with the required Authorization: Bearer API key. Upon successful processing, the APImage API returns a temporary URL for the newly processed image. The subsequent Download Image n8n node immediately fetches the actual processed binary file using the returned URL. Finally, the processed file is directed to the Store the output image n8n node (pre-configured here as a Google Drive n8n node), completing the automated n8n workflow by securely saving the final asset. This seamless n8n workflow exemplifies efficient automation.

Installation Guide


  1. Importing the n8n template: Copy the provided JSON code and paste it directly into your n8n instance using the "New" button and selecting "Import from JSON." This creates the full n8n workflow structure.

  2. API Key Setup (APImage API n8n node):

Obtain your API Key from the APImage Dashboard.
Double-click the APImage API n8n node to access its configuration.
Locate the Header Parameters section and replace the placeholder YOURAPIKEY_HERE in the Authorization header value with your actual key. This is essential for the n8n node to authenticate.

  1. Output Setup (Store the output image n8n node):

Configure the Store the output image Google Drive n8n node with your appropriate credentials and target folder ID.
* Alternatively, you can swap this n8n node for a different cloud storage, FTP, or database n8n node depending on where you need to save the final image. Many n8n templates utilize cloud storage for final output.

  1. Execution: Run the n8n workflow manually by executing the Replace Background n8n trigger or setting the workflow to active if using a different n8n trigger mechanism like a scheduled run.

Node Details

Replace Background (Form Trigger n8n node): This serves as the initial n8n trigger, capturing the input fields (Image URL and Background Description) needed for the image processing. As indicated in the workflow, this n8n node is intended to be replaceable by any data-providing n8n node.
APImage API (HTTP Request n8n node): This is the core processing n8n node. It initiates the background replacement via a POST request to the APImage API. Key configurations include setting the imageurl and backgroundprompt using expressions (={{ $json["Image URL"] }}) referencing data from the initial n8n trigger. Important parameters controlling the AI result are also set here, such as lightdirection and lightstrength.
Download Image (HTTP Request n8n node): A critical n8n node responsible for fetching the processed binary file. It uses an expression (={{ $json.data.url }}) to dynamically retrieve the temporary image URL returned by the previous APImage n8n node.
Store the output image (Google Drive n8n node): This final n8n node handles file persistence. It takes the binary file output from the download step and saves it to a specified Google Drive location. This can easily be exchanged for other file storage n8n templates.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

We at Gegenfeld are an EdTech platform dedicated to delivering high-quality on-demand courses and interactive training sessions for professional development at all skill levels. With our commitment to "Accelerate your future," we empower professionals to enhance their expertise through engaging, industry-focused learning experiences. On n8n, we share some of the workflows used in our interactive training to provide deeper insights and practical applications.

Featured*