  base64_str = base.numpy_to_base64(arr)
    time_str = time.strftime("%Y%m%d_%H%M%S")
    link = document.createElement("a")
    if len(event.data)>2 and event.data[2]:
        filename = event.data[2]
    else:
        filename = f"outpaint_{time_str}"
    # link.download = f"sdinf_state_{time_str}.json"
    link.download = f"{filename}.png"
    # link.download = f"outpaint_{time_str}.png"
    link.href = "data:image/png;base64,"+base64_str
    link.click()
    console.log(f"Canvas saved to {filename}.png