Stable Diffusion Base 64 to Image preview and download (jpg/png)

Describe the problem/error/question

I’m fairly new to N8N and have a limited knowledge when it comes to coding.

Basically, I was able to set up HTTP request to Stable Diffusion fairly easily, however I wasn’t expecting the response to be BASE 64.

I am trying view and hopefully download the image generated by Stable Diffusion API call.

I’ve researched the forum and tried some of the suggestion but they haven’t worked or I’ve not fully understood. Some of those attempts are included in the workflow

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker on EC2):
  • Operating system: Linux

Hi @luminysai
if the response from stability.ai is a base64, you need to use the Convert to/from binary data to convert that base64 in the JSON data to an actual file you can use in your workflow.
In Convert to/from binary data, select the mode to JSON to Binary. The Source Key should be the name of the input field that contains the actual base64.
Also, remember to set the options

  • Data Is Base64 toggle to ON
  • Mime Type to image/jpeg

Please check this workflow as a reference and let me know if you need more support.
All the best

5 Likes

@giulioandreini
Amazing!!!

Thank you so much for spending your time to respond!

2 Likes

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