Hermes Bot commited on
Commit ·
f1bf63c
1
Parent(s): 722713d
Add debug and fallback to gallery metadata handler
Browse files- ui/events/run_handlers.py +11 -5
ui/events/run_handlers.py
CHANGED
|
@@ -116,13 +116,19 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
|
|
| 116 |
)
|
| 117 |
# When a user selects an image from the global Gallery tab, load its generation info
|
| 118 |
def _show_meta(selected_path, *_):
|
|
|
|
| 119 |
try:
|
|
|
|
|
|
|
|
|
|
| 120 |
from PIL import Image
|
| 121 |
-
with Image.open(
|
| 122 |
-
meta = im.info.get(
|
| 123 |
-
except Exception:
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
| 126 |
# Connect the select event of the global gallery to update its metadata textbox
|
| 127 |
gallery_tab = ui_components.get('gallery')
|
| 128 |
if gallery_tab:
|
|
|
|
| 116 |
)
|
| 117 |
# When a user selects an image from the global Gallery tab, load its generation info
|
| 118 |
def _show_meta(selected_path, *_):
|
| 119 |
+
# `selected_path` may be a string (filepath) or a list of filepaths.
|
| 120 |
try:
|
| 121 |
+
# Normalise to a single path
|
| 122 |
+
path = selected_path[0] if isinstance(selected_path, (list, tuple)) else selected_path
|
| 123 |
+
print(f"[DEBUG] Gallery selected path: {path}")
|
| 124 |
from PIL import Image
|
| 125 |
+
with Image.open(path) as im:
|
| 126 |
+
meta = im.info.get("parameters", "")
|
| 127 |
+
except Exception as e:
|
| 128 |
+
print(f"[DEBUG] Failed to read metadata: {e}")
|
| 129 |
+
meta = ""
|
| 130 |
+
# If no metadata present, show a friendly placeholder.
|
| 131 |
+
return meta if meta else "(ไม่มีข้อมูลเมตาดาต้า)"
|
| 132 |
# Connect the select event of the global gallery to update its metadata textbox
|
| 133 |
gallery_tab = ui_components.get('gallery')
|
| 134 |
if gallery_tab:
|