mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-15 23:50:05 +08:00
to else block
This commit is contained in:
parent
eb84d6095f
commit
5c531364c2
@ -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'<a href="{url_string}" target="_blank">{link_text}</a>'
|
||||
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",
|
||||
|
||||
44
server.py
44
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'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user