preview replace save params
This commit is contained in:
parent
a0d07fb580
commit
abc4d3a693
|
@ -2,8 +2,10 @@ import glob
|
||||||
import os.path
|
import os.path
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from PIL import PngImagePlugin
|
||||||
|
|
||||||
from modules import shared
|
from modules import shared
|
||||||
|
from modules.images import read_info_from_image
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import json
|
import json
|
||||||
import html
|
import html
|
||||||
|
@ -290,6 +292,7 @@ def setup_ui(ui, gallery):
|
||||||
|
|
||||||
img_info = images[index if index >= 0 else 0]
|
img_info = images[index if index >= 0 else 0]
|
||||||
image = image_from_url_text(img_info)
|
image = image_from_url_text(img_info)
|
||||||
|
geninfo, items = read_info_from_image(image)
|
||||||
|
|
||||||
is_allowed = False
|
is_allowed = False
|
||||||
for extra_page in ui.stored_extra_pages:
|
for extra_page in ui.stored_extra_pages:
|
||||||
|
@ -299,6 +302,11 @@ def setup_ui(ui, gallery):
|
||||||
|
|
||||||
assert is_allowed, f'writing to {filename} is not allowed'
|
assert is_allowed, f'writing to {filename} is not allowed'
|
||||||
|
|
||||||
|
if geninfo:
|
||||||
|
pnginfo_data = PngImagePlugin.PngInfo()
|
||||||
|
pnginfo_data.add_text('parameters', geninfo)
|
||||||
|
image.save(filename, pnginfo=pnginfo_data)
|
||||||
|
else:
|
||||||
image.save(filename)
|
image.save(filename)
|
||||||
|
|
||||||
return [page.create_html(ui.tabname) for page in ui.stored_extra_pages]
|
return [page.create_html(ui.tabname) for page in ui.stored_extra_pages]
|
||||||
|
|
Loading…
Reference in New Issue