How to Send Image + Mask for Inpainting to Stable Diffusion API?

Hi everyone,

I’m working on a fun automation project and would love some advice on the best way to structure it in n8n.

My Goal:
I want to create a workflow that automatically removes logos from my product photos. The plan is to:

  1. Grab a specific product image from Google Drive.

  2. Send that image, along with a pre-made black and white “mask” image, to my local AUTOMATIC1111 server using the img2img API endpoint.

  3. The API will then use the image and mask to inpaint the logo area and remove it.

My Setup:

n8n Version: 1.103.2 (Self-hosted)
Image Source: Google Drive Search/Download nodes.
API: AUTOMATIC1111 Stable Diffusion WebUI (running locally, accessed via ngrok).

My Question:
I’m not sure about the correct way to handle the two images (the main image and the mask) in the HTTP Request node . As you can see from the workflow I shared, I entered the Base64 code in the JSON. I tried following Gemini’s instructions to set this all up, it worked well up to this point, but got stuck trying to solve this issue. Thank you for any help!

Hey @Nick_B

I would think its better to just pass in the binary, but you can try this also in the json

“init_images”: [“data:image/png;base64,{{ $binary.main.data.toString(‘base64’) }}”],
“mask”: “data:image/png;base64,{{ $binary.mask.data.toString(‘base64’) }}”,

Hopefully this sets the correct format for you, let me know if this works, can explore other options if neeeded.

Samuel

I think its better to use Send Binary Data: true
Body Content Type: multipart/form-data

And just reference in binarys after using a merge node.

Hope thats makes sense,

Samuel

Hi Samuel, thanks for the help, I decided to go with your recommendation instead of the base64 route, but it still isn’t working, I think I misunderstood you.

Could you maybe have a look please?