From 5c531364c26a0c6fddcf49b91add0f969ec52656 Mon Sep 17 00:00:00 2001 From: bilt Date: Thu, 31 Jul 2025 16:03:48 +0800 Subject: [PATCH] to else block --- comfy_extras/nodes_video.py | 27 ----------------------- server.py | 44 ++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/comfy_extras/nodes_video.py b/comfy_extras/nodes_video.py index 81efbe770..b608aacff 100644 --- a/comfy_extras/nodes_video.py +++ b/comfy_extras/nodes_video.py @@ -378,36 +378,10 @@ class LoadVideoEncrypted(ComfyNodeABC): return True -class DisplayLinkNode: - def __init__(self): - pass - - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "url_string": ("STRING", {"multiline": False}), - }, - "optional": { - "link_text": ("STRING", {"multiline": False}), - } - } - - RETURN_TYPES = ("STRING",) - OUTPUT_NODE = True - FUNCTION = "display_link" - CATEGORY = "image/video" - - def display_link(self, url_string, link_text): - # Create the HTML anchor tag - # The target="_blank" attribute opens the link in a new tab - html_link = f'{link_text}' - return (html_link,) NODE_CLASS_MAPPINGS = { "SaveWEBM": SaveWEBM, "SaveVideo": SaveVideo, - "DisplayLinkNode": DisplayLinkNode, "CreateVideo": CreateVideo, "GetVideoComponents": GetVideoComponents, "LoadVideo": LoadVideo, @@ -416,7 +390,6 @@ NODE_CLASS_MAPPINGS = { NODE_DISPLAY_NAME_MAPPINGS = { "SaveVideo": "Save Video", - "DisplayLinkNode": "Display Link", "CreateVideo": "Create Video", "GetVideoComponents": "Get Video Components", "LoadVideo": "Load Video", diff --git a/server.py b/server.py index f5d3df988..ac0b15f2c 100644 --- a/server.py +++ b/server.py @@ -525,30 +525,30 @@ class PromptServer(): return web.Response(body=alpha_buffer.read(), content_type='image/png', headers={"Content-Disposition": f"filename=\"{filename}\""}) - elif channel == 'rgba': - with Image.open(file) as img: - # 确保图像是 RGBA 模式 - if img.mode != 'RGBA': - if img.mode == 'RGB': - # RGB -> RGBA(Alpha=255) - new_img = img.convert('RGBA') - else: - # 其他模式(如 L/LA/P)-> RGBA - new_img = Image.new('RGBA', img.size, (0, 0, 0, 255)) - new_img.paste(img, (0, 0), img) # 保留原图的 Alpha(如果有) + # elif channel == 'rgba': + # with Image.open(file) as img: + # # 确保图像是 RGBA 模式 + # if img.mode != 'RGBA': + # if img.mode == 'RGB': + # # RGB -> RGBA(Alpha=255) + # new_img = img.convert('RGBA') + # else: + # # 其他模式(如 L/LA/P)-> RGBA + # new_img = Image.new('RGBA', img.size, (0, 0, 0, 255)) + # new_img.paste(img, (0, 0), img) # 保留原图的 Alpha(如果有) - else: - new_img = img # 已经是 RGBA,无需转换 + # else: + # new_img = img # 已经是 RGBA,无需转换 - # 保存为 PNG 并返回 - buffer = BytesIO() - new_img.save(buffer, format='PNG') - buffer.seek(0) - return web.Response( - body=buffer.read(), - content_type='image/png', - headers={"Content-Disposition": f"filename=\"{filename}\""} - ) + # # 保存为 PNG 并返回 + # buffer = BytesIO() + # new_img.save(buffer, format='PNG') + # buffer.seek(0) + # return web.Response( + # body=buffer.read(), + # content_type='image/png', + # headers={"Content-Disposition": f"filename=\"{filename}\""} + # ) else: # Get content type from mimetype, defaulting to 'application/octet-stream'