How to Correctly Merge a Filtered Data Stream with its Original Binary File?

Hi everyone,

I’m working on a workflow to process e-commerce product images, and I’m running into a common data merging problem. I would appreciate any advice on the best n8n pattern to solve this.

My Goal:

  1. Start with a list of image URLs from a Google Sheet.

  2. Download all the images.

  3. For each image, use the Google Gemini (AI) node to analyze whether a watermark is placed over a person’s hand.

  4. Split the workflow into two branches: one for images that pass the check (logo is on a hand) and one for images that fail.

  5. Crucially, both branches need to have the full item, including the downloaded binary image file and its corresponding analysis data.

The Problem I’m Facing:

I’ve correctly set up parallel branches:

  • Branch A (Downloads): Code5 → Filter1 → Download_Images1 → … This branch successfully downloads the binary files.

  • Branch B (Analysis): The same Filter1 output → Analyze_Images → Filter (Code Node) → If. This branch correctly analyzes the images and the If node splits the JSON data.

The issue is that the Analyze_Images node does not pass through the binary data it receives. My final Merge node (which is supposed to combine the downloaded files from Branch A with the filtered JSON from Branch B) is failing because I can’t find a reliable way to match the items from the two branches.

I thought about adding a unique index to each item, splitting the branches, and then using a final Merge node to combine them based on this index. However, I’m struggling to get the wiring and the Merge node configuration just right.

My Question:

What is the correct n8n pattern to solve this? How can I reliably re-combine my stream of downloaded binary files with the corresponding JSON data after that data has been filtered by an If node?

Thank you in advance for your help

Consider processing one image at a time?
like download only one image and then doing analysis(or whatever you want to do) and download second image and so on?

Hi Moosa, thank you for the recommendation, but I don’t think I can, that is not the whole workflow, those images need to be together to go through the rest of the workflow.

Also, the analyze image does not output binary, which is why I need to somehow combine the data that passes through the If node and match it to the binary file. Unless there is a way to pass the binary file through the analyze image and if nodes, which would make things way simpler…

when you use set or code node after a node which outputs binary data and does not output binary from them(code, set) then binary can not be accessed down the line.

but in your case you have urls of images. With which you can download images again!!!

but you can also access that data in later nodes like

2 Likes

Oh yea, that makes sense, I think I figured it out now, I was overcomplicating the whole workflow. Thank you Moosa for helping me take a step back and look at the issue differently. :slight_smile: Have a good day!

1 Like