mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-01-07 17:52:17 -08:00
make pasting into img2img prompt work
make image params request not use temp files
This commit is contained in:
parent
33ae6be55e
commit
0aec19d783
2 changed files with 20 additions and 23 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import io
|
||||
import math
|
||||
import os
|
||||
from collections import namedtuple
|
||||
|
|
@ -465,21 +466,20 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
|
|||
return fullfn, txt_fullfn
|
||||
|
||||
|
||||
def image_data(image_path):
|
||||
file, ext = os.path.splitext(image_path.name)
|
||||
data = {}
|
||||
if "png" in ext:
|
||||
image = Image.open(image_path.name, "r")
|
||||
print(f"Image data requested for {image_path.name} {image.format} of {type(image)}")
|
||||
try:
|
||||
data = image.text["parameters"]
|
||||
except Exception as e:
|
||||
print(f"Exception: {e}")
|
||||
pass
|
||||
print(f"Image data: {data}")
|
||||
if "txt" in ext:
|
||||
myfile = open(image_path.name, 'r')
|
||||
data = myfile.read()
|
||||
myfile.close()
|
||||
def image_data(data):
|
||||
try:
|
||||
image = Image.open(io.BytesIO(data))
|
||||
textinfo = image.text["parameters"]
|
||||
return textinfo, None
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return data, None
|
||||
try:
|
||||
text = data.decode('utf8')
|
||||
assert len(text) < 10000
|
||||
return text, None
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return '', None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue