How can I center the upper image in the composite operation of the "Edit Image" node?

Hi everyone,

I’m using the “Edit Image” node to put one image on top of another using the “Composite” operation.
The width and height of the image changes. So sometimes it is vertical, sometimes it is horizontal.

I would like to anchor the image center of the upper image, to one specific spot on the bottom image.

As seen in the image below, I can only add the “Position X” and “Position Y” using pixels. Is it possible to center it somehow? or set a specific space where the image should be “contained”?

I’m running n8n via Docker.

Thanks,
René

Hi @renetheastronaut, welcome to the community, I hope you’re well? Unfortunately I don’t have any first hand experience with this node but I can see this has already been flagged to @harshil1712 who has used the node extensively. Let’s see if he has any additional insights here :slight_smile:

3 Likes

Hey @renetheastronaut,

Welcome to the community :tada:

If I understand your question correctly, the incoming images have a dynamic height and width, right? If that’s the case, then you will have to write a function in the Function node to calculate the values and use them.

Hey @harshil1712 ,

Thanks a lot. That was a great idea. I added another “Edit Image” node and selected “Get Image Information”. After this I was able to calculate the pixels dynamically directly inside of the expression field.

Thanks a lot!

Have a great day.
René

1 Like

Hey!

Thank you for sharing the solution. I wasn’t aware of the complexity, but I love your solution.

2 Likes