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_colorvalue to any valid CSS color (e.g., “#FF0000” for red) to get different background color instead of white or transparent. - Adjust Padding: Modify the
paddingparameter 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
keepInputSizetotrueto keep original image dimensions orfalseto use a fixed size like 1600×1600. - Change Output Folder: Update
OutputDriveFolderin Config to redirect processed images to another folder in your Google Drive. - Name Convention: Modify the
Upload Picture to Google Drivenodes’ 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!