SD_api_pictures: Fix for metadata (#1082)
This commit is contained in:
parent
5ad92c940e
commit
1d8526849b
2 changed files with 32 additions and 15 deletions
|
@ -138,14 +138,19 @@ def get_SD_pictures(description):
|
|||
|
||||
visible_result = ""
|
||||
for img_str in r['images']:
|
||||
image = Image.open(io.BytesIO(base64.b64decode(img_str.split(",", 1)[0])))
|
||||
if params['save_img']:
|
||||
img_data = base64.b64decode(img_str)
|
||||
|
||||
variadic = f'{date.today().strftime("%Y_%m_%d")}/{shared.character}_{int(time.time())}'
|
||||
output_file = Path(f'extensions/sd_api_pictures/outputs/{variadic}.png')
|
||||
output_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
image.save(output_file.as_posix())
|
||||
|
||||
with open(output_file.as_posix(), 'wb') as f:
|
||||
f.write(img_data)
|
||||
|
||||
visible_result = visible_result + f'<img src="/file/extensions/sd_api_pictures/outputs/{variadic}.png" alt="{description}" style="max-width: unset; max-height: unset;">\n'
|
||||
else:
|
||||
image = Image.open(io.BytesIO(base64.b64decode(img_str.split(",", 1)[0])))
|
||||
# lower the resolution of received images for the chat, otherwise the log size gets out of control quickly with all the base64 values in visible history
|
||||
image.thumbnail((300, 300))
|
||||
buffered = io.BytesIO()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue