mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-28 10:25:41 +08:00
to else block
This commit is contained in:
parent
eb84d6095f
commit
5c531364c2
@ -378,36 +378,10 @@ class LoadVideoEncrypted(ComfyNodeABC):
|
|||||||
return True
|
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'<a href="{url_string}" target="_blank">{link_text}</a>'
|
|
||||||
return (html_link,)
|
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"SaveWEBM": SaveWEBM,
|
"SaveWEBM": SaveWEBM,
|
||||||
"SaveVideo": SaveVideo,
|
"SaveVideo": SaveVideo,
|
||||||
"DisplayLinkNode": DisplayLinkNode,
|
|
||||||
"CreateVideo": CreateVideo,
|
"CreateVideo": CreateVideo,
|
||||||
"GetVideoComponents": GetVideoComponents,
|
"GetVideoComponents": GetVideoComponents,
|
||||||
"LoadVideo": LoadVideo,
|
"LoadVideo": LoadVideo,
|
||||||
@ -416,7 +390,6 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"SaveVideo": "Save Video",
|
"SaveVideo": "Save Video",
|
||||||
"DisplayLinkNode": "Display Link",
|
|
||||||
"CreateVideo": "Create Video",
|
"CreateVideo": "Create Video",
|
||||||
"GetVideoComponents": "Get Video Components",
|
"GetVideoComponents": "Get Video Components",
|
||||||
"LoadVideo": "Load Video",
|
"LoadVideo": "Load Video",
|
||||||
|
|||||||
44
server.py
44
server.py
@ -525,30 +525,30 @@ class PromptServer():
|
|||||||
return web.Response(body=alpha_buffer.read(), content_type='image/png',
|
return web.Response(body=alpha_buffer.read(), content_type='image/png',
|
||||||
headers={"Content-Disposition": f"filename=\"{filename}\""})
|
headers={"Content-Disposition": f"filename=\"{filename}\""})
|
||||||
|
|
||||||
elif channel == 'rgba':
|
# elif channel == 'rgba':
|
||||||
with Image.open(file) as img:
|
# with Image.open(file) as img:
|
||||||
# 确保图像是 RGBA 模式
|
# # 确保图像是 RGBA 模式
|
||||||
if img.mode != 'RGBA':
|
# if img.mode != 'RGBA':
|
||||||
if img.mode == 'RGB':
|
# if img.mode == 'RGB':
|
||||||
# RGB -> RGBA(Alpha=255)
|
# # RGB -> RGBA(Alpha=255)
|
||||||
new_img = img.convert('RGBA')
|
# new_img = img.convert('RGBA')
|
||||||
else:
|
# else:
|
||||||
# 其他模式(如 L/LA/P)-> RGBA
|
# # 其他模式(如 L/LA/P)-> RGBA
|
||||||
new_img = Image.new('RGBA', img.size, (0, 0, 0, 255))
|
# new_img = Image.new('RGBA', img.size, (0, 0, 0, 255))
|
||||||
new_img.paste(img, (0, 0), img) # 保留原图的 Alpha(如果有)
|
# new_img.paste(img, (0, 0), img) # 保留原图的 Alpha(如果有)
|
||||||
|
|
||||||
else:
|
# else:
|
||||||
new_img = img # 已经是 RGBA,无需转换
|
# new_img = img # 已经是 RGBA,无需转换
|
||||||
|
|
||||||
# 保存为 PNG 并返回
|
# # 保存为 PNG 并返回
|
||||||
buffer = BytesIO()
|
# buffer = BytesIO()
|
||||||
new_img.save(buffer, format='PNG')
|
# new_img.save(buffer, format='PNG')
|
||||||
buffer.seek(0)
|
# buffer.seek(0)
|
||||||
return web.Response(
|
# return web.Response(
|
||||||
body=buffer.read(),
|
# body=buffer.read(),
|
||||||
content_type='image/png',
|
# content_type='image/png',
|
||||||
headers={"Content-Disposition": f"filename=\"{filename}\""}
|
# headers={"Content-Disposition": f"filename=\"{filename}\""}
|
||||||
)
|
# )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Get content type from mimetype, defaulting to 'application/octet-stream'
|
# Get content type from mimetype, defaulting to 'application/octet-stream'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user