Add save image browse and external preview

This commit is contained in:
2026-08-05 13:15:39 +00:00
parent 17f7adba65
commit 8191dabb61
4 changed files with 86 additions and 5 deletions
+17
View File
@@ -3,6 +3,8 @@ import os
import random
import re
import time
import uuid
from collections import OrderedDict
import numpy as np
from PIL import Image
@@ -14,6 +16,8 @@ _MEDIA_EXT_RE = re.compile(
r"\.(png|jpe?g|webp|gif|bmp|tiff?|avif|mp4|mov|webm|mkv|m4v)$", re.IGNORECASE
)
_DATE_TOKEN_RE = re.compile(r"%date:([^%]+)%")
_SERVE_TOKENS = OrderedDict()
_SERVE_CAP = 256
def _clean_input_token_value(value):
@@ -95,6 +99,18 @@ def _safe_pattern(value):
return value
def _register_serve_token(path):
token = uuid.uuid4().hex
_SERVE_TOKENS[token] = path
while len(_SERVE_TOKENS) > _SERVE_CAP:
_SERVE_TOKENS.popitem(last=False)
return token
def resolve_serve_token(token):
return _SERVE_TOKENS.get(str(token or ""))
def _is_within_directory(parent_path, child_path):
try:
return os.path.commonpath([parent_path, child_path]) == parent_path
@@ -378,6 +394,7 @@ class DumasSaveImageNode:
"filename": filename,
"subfolder": frame_dir.replace("\\", "/"),
"type": "external",
"token": _register_serve_token(full_path),
}
)