updates to transparency filtering, fixing mass tag edit autocomplete
This commit is contained in:
+32
-29
@@ -822,46 +822,49 @@ def get_tag_image_count(tag_id):
|
||||
|
||||
@main.get("/api/import-settings")
|
||||
def get_import_settings():
|
||||
"""Get current import filter settings."""
|
||||
# Load from file first, fall back to env defaults
|
||||
import json
|
||||
settings_path = "/import/settings.json"
|
||||
"""Get current import filter settings from database."""
|
||||
from app.utils.version_migration import (
|
||||
get_setting_int, get_setting_float, get_setting_bool
|
||||
)
|
||||
|
||||
settings = {
|
||||
"min_width": int(os.environ.get("IMPORT_MIN_WIDTH", "0")),
|
||||
"min_height": int(os.environ.get("IMPORT_MIN_HEIGHT", "0")),
|
||||
"skip_transparent": os.environ.get("IMPORT_SKIP_TRANSPARENT", "false").lower() == "true",
|
||||
"transparency_threshold": float(os.environ.get("IMPORT_TRANSPARENCY_THRESHOLD", "0.9")),
|
||||
"phash_threshold": int(os.environ.get("IMPORT_PHASH_THRESHOLD", "2")),
|
||||
"min_width": get_setting_int("import_min_width", int(os.environ.get("IMPORT_MIN_WIDTH", "0"))),
|
||||
"min_height": get_setting_int("import_min_height", int(os.environ.get("IMPORT_MIN_HEIGHT", "0"))),
|
||||
"skip_transparent": get_setting_bool("import_skip_transparent", os.environ.get("IMPORT_SKIP_TRANSPARENT", "false").lower() == "true"),
|
||||
"transparency_threshold": get_setting_float("import_transparency_threshold", float(os.environ.get("IMPORT_TRANSPARENCY_THRESHOLD", "0.9"))),
|
||||
"phash_threshold": get_setting_int("phash_threshold", int(os.environ.get("IMPORT_PHASH_THRESHOLD", "10"))),
|
||||
}
|
||||
try:
|
||||
if os.path.exists(settings_path):
|
||||
with open(settings_path, "r") as f:
|
||||
file_settings = json.load(f)
|
||||
settings.update(file_settings)
|
||||
except Exception:
|
||||
pass
|
||||
return jsonify(ok=True, settings=settings)
|
||||
|
||||
|
||||
@main.post("/api/import-settings")
|
||||
def save_import_settings():
|
||||
"""
|
||||
Save import filter settings.
|
||||
Settings are stored in /import/settings.json and loaded by the importer.
|
||||
Save import filter settings to database.
|
||||
Settings are loaded by the Celery workers via load_import_settings().
|
||||
"""
|
||||
settings = {
|
||||
"min_width": request.form.get("min_width", 0, type=int),
|
||||
"min_height": request.form.get("min_height", 0, type=int),
|
||||
"skip_transparent": request.form.get("skip_transparent") == "true",
|
||||
"transparency_threshold": request.form.get("transparency_threshold", 0.9, type=float),
|
||||
"phash_threshold": request.form.get("phash_threshold", 2, type=int),
|
||||
}
|
||||
from app.utils.version_migration import set_setting
|
||||
|
||||
min_width = request.form.get("min_width", 0, type=int)
|
||||
min_height = request.form.get("min_height", 0, type=int)
|
||||
skip_transparent = request.form.get("skip_transparent") == "true"
|
||||
transparency_threshold = request.form.get("transparency_threshold", 0.9, type=float)
|
||||
phash_threshold = request.form.get("phash_threshold", 10, type=int)
|
||||
|
||||
import json
|
||||
settings_path = "/import/settings.json"
|
||||
try:
|
||||
with open(settings_path, "w") as f:
|
||||
json.dump(settings, f, indent=2)
|
||||
set_setting("import_min_width", str(min_width))
|
||||
set_setting("import_min_height", str(min_height))
|
||||
set_setting("import_skip_transparent", str(skip_transparent).lower())
|
||||
set_setting("import_transparency_threshold", str(transparency_threshold))
|
||||
set_setting("phash_threshold", str(phash_threshold))
|
||||
|
||||
settings = {
|
||||
"min_width": min_width,
|
||||
"min_height": min_height,
|
||||
"skip_transparent": skip_transparent,
|
||||
"transparency_threshold": transparency_threshold,
|
||||
"phash_threshold": phash_threshold,
|
||||
}
|
||||
return jsonify(ok=True, settings=settings)
|
||||
except Exception as e:
|
||||
return jsonify(ok=False, error=str(e)), 500
|
||||
|
||||
Reference in New Issue
Block a user