How to use Edit Image Compose with an array of Images?

Describe the problem/error/question

Please be kind. I want to understand how things are going and simplified my workflow to highlight the problem I have.

I have an array of images after the last node. I lack understanding on the composite function of the edit node. I want to consolidate/compose all images in the array into one image. I am not sure how to achieve that.

Sorry. I am new to all of this … and must say … I love it!

What is the error message (if any)?

No. Error.

Please share your workflow

Share the output returned by the last node

My last node returns an array of 6 binary objects representing the rendered text individually. I am missing the nodes/code/idea how to consolidate those 6 images into one via Edit Image … compose.

Information on your n8n setup

  • n8n version: 1.49.0
  • Database (default: SQLite): Postgress
  • n8n EXECUTIONS_PROCESS setting (default: own, main): I dont know what to answer here, sorry.
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian

You’d need to do it in multiple steps, adding an item at each step.

Thanks for trying to help. I would like to avoid to do it manually, because I want the data to define content (which text, how many).

I figured out a way to reference JSON data from previous loop. As well I figerd out how to reference binary data from input and provide it to output.

The only point missing is how to reference binary data in a code block FROM PREVIOUS LOOP and thus providing the current canvas and the previous canvas for the composite node.

If you run this workflow you see that in the Composite Node I have access to this loops data plus the previous loops JSON data and was able to create two binary objects. Currently BOTH referencing the current loops binary data.

The only piece missing is … how to reference binary data in a code output block from a previous loop. I hope someone can help me.

This provides the current loops canvas to the output.

let canvasBuffer = await this.helpers.getBinaryDataBuffer(0, 'canvas');
let r = {};
r.binary = {
  canvas: await this.helpers.prepareBinaryData(canvasBuffer, '')
};

I need the equivalent to

let previousCanvasBuffer = await this.helpers.getBinaryDataBuffer(0, 'canvas');

Would something like this work?

2 Likes

Thanks a ton! What a few lines of code can do is amazing. This is a step in the right direction. I will look into this, to see how I can transfer your concept into my specific workflow.

One caveat is that the number of texts is now “fixed” to number of steps in the Edit Image Multi Step Node, but in principle it works as expected.

I need to see what I can do with it. Much appreciated! Thank you.

1 Like

I think it’d be nice to have something like a “Merge all images” operation built into the node. Maybe I’ll try to implement it one of these days. If I do, I’ll post here.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.