diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py
index 8d606352..87216a15 100644
--- a/extensions/gallery/script.py
+++ b/extensions/gallery/script.py
@@ -4,6 +4,8 @@ from pathlib import Path
import gradio as gr
+from modules.html_generator import image_to_base64
+
def generate_html():
css = """
@@ -29,10 +31,14 @@ def generate_html():
background-color: gray;
}
- .character-gallery td {
- text-align: center;
- vertical-align: middle;
+ .character-gallery .image-td {
+ width: 150px;
}
+
+ .character-gallery .character-td {
+ text-align: center !important;
+ }
+
"""
table_html = f'
'
@@ -41,15 +47,25 @@ def generate_html():
for file in Path("characters").glob("*"):
if file.name.endswith(".json"):
json_name = file.name
- image_name = file.name.replace(".json", "")
+ character = file.name.replace(".json", "")
table_html += ""
- if Path(f"characters/{image_name}.png").exists():
- image_html = f''
- elif Path(f"characters/{image_name}.jpg").exists():
- image_html = f''
- else:
- image_html = ""
- table_html += f"{image_html} | {image_name} | "
+ image_html = ""
+
+ for i in [
+ f"characters/{character}.png",
+ f"characters/{character}.jpg",
+ f"characters/{character}.jpeg",
+ ]:
+
+ path = Path(i)
+ if path.exists():
+ try:
+ image_html = f''
+ break
+ except:
+ continue
+
+ table_html += f'{image_html} | {character} | '
table_html += "
"
table_html += "
"
diff --git a/modules/html_generator.py b/modules/html_generator.py
index 6e1fb8ac..dc2aa387 100644
--- a/modules/html_generator.py
+++ b/modules/html_generator.py
@@ -200,7 +200,7 @@ def image_to_base64(path):
if (path in image_cache and mtime != image_cache[path][0]) or (path not in image_cache):
img = Image.open(path)
- img.thumbnail((100, 100))
+ img.thumbnail((200, 200))
img_buffer = BytesIO()
img.convert('RGB').save(img_buffer, format='PNG')
image_cache[path] = [mtime, base64.b64encode(img_buffer.getvalue()).decode("utf-8")]