Simplify preview thumbnail options.
This commit is contained in:
10
__init__.py
10
__init__.py
@@ -183,7 +183,7 @@ def ui_rules():
|
|||||||
Rule("model-show-add-button", True, bool),
|
Rule("model-show-add-button", True, bool),
|
||||||
Rule("model-show-copy-button", True, bool),
|
Rule("model-show-copy-button", True, bool),
|
||||||
Rule("model-info-button-on-left", False, 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-embedding-extension", False, bool),
|
||||||
Rule("model-add-drag-strict-on-field", False, bool),
|
Rule("model-add-drag-strict-on-field", False, bool),
|
||||||
Rule("model-add-offset", 25, int),
|
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")
|
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):
|
def get_auto_thumbnail_format(original_format):
|
||||||
if original_format in ["JPEG", "WEBP", "JPG"]:
|
if original_format in ["JPEG", "WEBP", "JPG"]:
|
||||||
return original_format
|
return original_format
|
||||||
@@ -351,7 +347,7 @@ async def get_model_preview(request):
|
|||||||
image_format = image.format
|
image_format = image.format
|
||||||
if response_image_format is None:
|
if response_image_format is None:
|
||||||
response_image_format = image_format
|
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)
|
response_image_format = get_auto_thumbnail_format(image_format)
|
||||||
|
|
||||||
if not image_format_is_equal(response_image_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
|
image_format = image.format
|
||||||
if response_image_format is None:
|
if response_image_format is None:
|
||||||
response_image_format = image_format
|
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)
|
response_image_format = get_auto_thumbnail_format(image_format)
|
||||||
|
|
||||||
w0, h0 = image.size
|
w0, h0 = image.size
|
||||||
|
|||||||
@@ -3401,7 +3401,7 @@ class SettingsView {
|
|||||||
$select({
|
$select({
|
||||||
$: (el) => (settings["model-preview-thumbnail-type"] = el),
|
$: (el) => (settings["model-preview-thumbnail-type"] = el),
|
||||||
textContent: "Preview thumbnail type",
|
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"]),
|
$el("h2", ["Model Add"]),
|
||||||
$checkbox({
|
$checkbox({
|
||||||
|
|||||||
Reference in New Issue
Block a user