stablediffusion-infinity icon indicating copy to clipboard operation
stablediffusion-infinity copied to clipboard

Save the image locally instead of downloading it ?

Open baristerzi opened this issue 3 years ago • 1 comments

Hello, How can I get the canvas to save locally when I click on Export instead of downloading it? I struggled a bit and it brought me to the function below. However, I don't know async function, so I couldn't figure it out. Thanks.

async def export_func(event): base=base_lst[0] arr=base.export() base.draw_buffer() base.canvas[2].clear() base64_str = base.numpy_to_base64(arr) time_str = time.strftime("%Y%m%d_%H%M%S") console.log(f"Canvas saved to outpaint_{time_str}.png") link = document.createElement("a") link.download = f"outpaint_{time_str}.png" link.href = "data:image/png;base64,"+base64_str link.click()

baristerzi avatar Oct 22 '22 19:10 baristerzi

That's a limitation of the browser API: https://stackoverflow.com/questions/11336663/how-to-make-a-browser-display-a-save-as-dialog-so-the-user-can-save-the-conten

Not all browsers support open the "save as" dialog programmatically. So I did not implement this.

lkwq007 avatar Oct 23 '22 04:10 lkwq007