🎬 Automatically replace and relight the background of any image using APImage

⚑ 301 views · 🎬 Content Creation & Video

Description

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.

APImage Replace Background Example.png


Who This Workflow is For

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


How the Workflow Works

Replace and Relight image background for product images APImage n8n workflow.jpg

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)  β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

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

How to Customize the Workflow

Example Use Cases

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

πŸ”— Nodes Used

HTTP Request, Google Drive, n8n Form Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup