mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-31 02:32:57 +08:00
util decode_base64_to_image
This commit is contained in:
parent
9d39380705
commit
d36b732f55
@ -211,3 +211,13 @@ Requested path was: {path}
|
|||||||
subprocess.Popen(["wsl-open", path])
|
subprocess.Popen(["wsl-open", path])
|
||||||
else:
|
else:
|
||||||
subprocess.Popen(["xdg-open", path])
|
subprocess.Popen(["xdg-open", path])
|
||||||
|
|
||||||
|
|
||||||
|
def decode_base64_to_image(base64_str: str):
|
||||||
|
from modules import images
|
||||||
|
from io import BytesIO
|
||||||
|
import base64
|
||||||
|
if base64_str.startswith("data:image/"):
|
||||||
|
base64_str = base64_str.partition(';')[2].partition(',')[2]
|
||||||
|
image = images.read(BytesIO(base64.b64decode(base64_str)))
|
||||||
|
return image
|
||||||
|
Loading…
Reference in New Issue
Block a user