Background Removal Automation with n8n & Google Drive

This workflow automates background removal from images uploaded to Google Drive using Photoroom API. It saves time by processing images automatically with customized settings and re-uploading them to Drive.
set
httpRequest
googleDrive
+7
Learn how to Build this Workflow with AI:
Workflow Identifier: 1682
NODES in Use: Set, HTTP Request, Split Out, Google Drive Trigger, Google Drive, Edit Image, Split In Batches, If, Merge, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Alex, an ecommerce manager for a small but growing online store that sells handcrafted products. Every week, Alex receives dozens of product images that need backgrounds removed to maintain a consistent and professional look on the website and marketing material. Manually editing these images using photo tools takes hours—sometimes days—leading to delays in product launches and extra costs paying freelancers. Alex also struggles to add padding and keeps the image dimensions consistent, which creates additional rework.

This workflow solves exactly this: automatically removing backgrounds and enhancing images right after new uploads to Google Drive. It eliminates manual work, speeds up image preparation, and ensures quality output tailored to ecommerce needs.

2. What This Automation Does

This custom n8n workflow watches a specific Google Drive folder for new images, downloads them, sends them to the Photoroom API to remove or customize their backgrounds, and uploads the processed images back to Google Drive with new names. Specifically, it:

  • Detects new image uploads in a designated Google Drive folder automatically.
  • Downloads the original images including their metadata (e.g., filename).
  • Checks original image size and offers options to keep the input size or use a fixed output size (like 1600×1600 pixels).
  • Removes or changes the background color of images using the Photoroom API with padding and background customization.
  • Uploads the processed images back to Google Drive in a designated output folder with a clear naming convention indicating background removal.
  • Processes images in batches for efficiency and scalability.

Overall, Alex saves several hours weekly by automating image background removal, reducing errors and improving product image consistency.

3. Prerequisites ⚙️

  • Google Drive account with OAuth2 credentials set up for n8n Google Drive nodes 📁🔐
  • Photoroom API key for background removal service 🔑
  • n8n account or self-hosted instance to run workflows ⏱️
  • Basic knowledge of how to navigate the n8n workflow editor
  • Access to the Google Drive folder URLs for input and output folders

4. Step-by-Step Guide

Step 1: Configure Google Drive Trigger to Watch Input Folder

In n8n, click Add Node → select Google Drive Trigger. Set the event to fileCreated to respond to new uploads. Choose the specific Google Drive folder to monitor, ensuring it’s the one where your images will be uploaded.

You should see the trigger activating every minute, ready to detect new images.

Common mistake: Forgetting to provide the folder path will cause the workflow to watch the entire Drive, which may overload the process.

Step 2: Download Image from Google Drive

Add the Google Drive node, set operation to download, and map the fileId from the trigger. This downloads the image binary to send to the background removal API.

Expected outcome: image data is ready for processing.

Step 3: Get Image Size Using Edit Image Node

Add the Edit Image node with the operation set to information to read the original image dimensions. This data is used later to decide output size.

Image dimensions are retrieved into JSON outputs under the key for geometry.

Step 4: Split Image Size Data for Parallel Processing

Add the Split Out node pointing to the ‘Geometry’ field to split image size data if needed. It enables handling multiple dimension formats.

Step 5: Configure Parameters With Set Node

Add the Set node named Config. Here input these parameters:

  • bg_color: background color string, e.g. “white” or “transparent”
  • padding: padding percentage, e.g., “5%”
  • keepInputSize: boolean true/false, to keep original image size or use fixed
  • outputSize: output dimension string like “1600×1600”
  • inputFileName: map filename from downloaded image
  • OutputDriveFolder: paste your target Google Drive folder URL for uploads
  • api-key: your Photoroom API key

This centralizes key customization.

Step 6: Loop Over Images in Batches

Add the Split In Batches node and connect it to the merge node to handle multiple images if uploaded simultaneously.

Step 7: Conditional to Choose Output Size Method

Add the If node to check keepInputSize. If false, call the HTTP Request node for fixed size remove background; if true, call the one for keeping the input size.

Step 8: Remove Background Using Photoroom API

Add two HTTP Request nodes:

  • remove background fixed size sends the image with parameters including fixed output size from Config.
  • remove background sends the image using actual input size geometry.

Both POST to https://image-api.photoroom.com/v2/edit with multipart form data including image binary, background color, padding, and output size. The API key is passed in the header.

Ensure contentType is multipart-form-data.

Step 9: Upload Processed Image Back to Google Drive

Add two Google Drive upload nodes to save processed images. The filename is created dynamically by prefixing “BG-Removed-” and changing extension to .png.

Files are saved in the output folder specified in Config node.

5. Customizations ✏️

  • Change Background Color: In the Config node, update the bg_color value to any valid CSS color (e.g., “#FF0000” for red) to get different background color instead of white or transparent.
  • Adjust Padding: Modify the padding parameter in Config to add more or less space around the images (e.g., “10%” for extra padding).
  • Toggle Output Size: In the Config node, set keepInputSize to true to keep original image dimensions or false to use a fixed size like 1600×1600.
  • Change Output Folder: Update OutputDriveFolder in Config to redirect processed images to another folder in your Google Drive.
  • Name Convention: Modify the Upload Picture to Google Drive nodes’ filename expression if you want a different naming scheme.

6. Troubleshooting 🔧

Problem: Workflow does not trigger on new Google Drive files.
Cause: Incorrect folder selected or permissions not granted for Google Drive Trigger.
Solution: Double-check the folder path in the Google Drive Trigger node. Reauthenticate Google Drive credentials.

Problem: API returns authentication error or no response.
Cause: Invalid or missing Photoroom API key.
Solution: Verify your API key in the Config node is correctly entered. Regenerate if needed from Photoroom dashboard.

Problem: Images uploaded but no background removal effect.
Cause: Improper HTTP request body or headers.
Solution: Ensure HTTP Request nodes use POST with correct multipart-form-data. Confirm header “x-api-key” matches your API key.

7. Pre-Production Checklist ✅

  • Confirm Google Drive OAuth2 credentials are active and have file read/write permissions.
  • Test API key with a direct call to Photoroom API playground.
  • Verify folder URLs for input and output folders in the Config node.
  • Upload a test image manually to the input Drive folder and watch the workflow run.
  • Check the output folder for newly processed images with expected naming.

8. Deployment Guide

Activate the workflow by toggling Active in n8n. It will poll the input folder every minute automatically, processing images as they arrive.

Monitor periodically via n8n’s execution log to check for failures. The workflow has built-in batch processing for scalability.

9. FAQs

Q: Can I use other image background removal APIs instead of Photoroom?
A: Yes, but you’ll need to adjust the HTTP Request node URL, headers, and body parameters accordingly.

Q: Will this use much of my Google Drive API quota?
A: It uses standard read/write operations which are usually within free quotas unless processing very high volumes.

Q: Is the workflow secure?
A: Yes, your credentials remain private within n8n. API keys are securely stored in credential nodes.

10. Conclusion

You’ve just automated Alex’s tedious task of removing backgrounds from product images stored on Google Drive. This workflow saves valuable time, reduces human error, and delivers consistent output images with optional padding and size control.

With this automation, you could easily scale your store’s product photography process or extend it to other visual content preparation tasks. Next steps could include integrating AI for image tagging or sending images to ecommerce platforms directly.

Enjoy your new automated image workflow and watch your productivity soar!

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free