From 55ddaa19bda2d8cdd201bb0d03d4d43a907dc3f3 Mon Sep 17 00:00:00 2001 From: Christian Bastian <80225746+cdb-boop@users.noreply.github.com> Date: Sun, 21 Jul 2024 02:53:07 -0400 Subject: [PATCH] Simplify preview thumbnail options. --- __init__.py | 10 +++------- web/model-manager.js | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index db85220..87f722c 100644 --- a/__init__.py +++ b/__init__.py @@ -183,7 +183,7 @@ def ui_rules(): Rule("model-show-add-button", True, bool), Rule("model-show-copy-button", True, bool), Rule("model-info-button-on-left", False, bool), - Rule("model-preview-thumbnail-type", "JPEG/WEBP", str), + Rule("model-preview-thumbnail-type", "AUTO", str), Rule("model-add-embedding-extension", False, bool), Rule("model-add-drag-strict-on-field", False, bool), Rule("model-add-offset", 25, int), @@ -292,10 +292,6 @@ def image_format_is_equal(f1, f2): return f1 == f2 or (f1 == "JPG" and f2 == "JPEG") or (f1 == "JPEG" and f2 == "JPG") -def is_auto_thumbnail_format(format): - return format in ["JPEG/WEBP", "WEBP/JPEG", "JPG/WEBP", "WEBP/JPG"] - - def get_auto_thumbnail_format(original_format): if original_format in ["JPEG", "WEBP", "JPG"]: return original_format @@ -351,7 +347,7 @@ async def get_model_preview(request): image_format = image.format if response_image_format is None: response_image_format = image_format - elif is_auto_thumbnail_format(response_image_format): + elif response_image_format == "AUTO": response_image_format = get_auto_thumbnail_format(image_format) if not image_format_is_equal(response_image_format, image_format): @@ -373,7 +369,7 @@ async def get_model_preview(request): image_format = image.format if response_image_format is None: response_image_format = image_format - elif is_auto_thumbnail_format(response_image_format): + elif response_image_format == "AUTO": response_image_format = get_auto_thumbnail_format(image_format) w0, h0 = image.size diff --git a/web/model-manager.js b/web/model-manager.js index c2ab118..4072ee6 100644 --- a/web/model-manager.js +++ b/web/model-manager.js @@ -3401,7 +3401,7 @@ class SettingsView { $select({ $: (el) => (settings["model-preview-thumbnail-type"] = el), textContent: "Preview thumbnail type", - options: ["JPEG/WEBP", "JPEG"], // should use JPEG/WEBP to avoid artifacts from changing between formats; use JPEG for backward compatibility + options: ["AUTO", "JPEG"], // should use AUTO to avoid artifacts from changing between formats; use JPEG for backward compatibility }), $el("h2", ["Model Add"]), $checkbox({