Skip to content

Commit fd1df10

Browse files
committed
modified the ImageConcanateOfUtils node to support six images.
1 parent 06e0b5b commit fd1df10

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

nodes.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -366,29 +366,45 @@ def INPUT_TYPES(s):
366366
{
367367
"default": 'right'
368368
}),
369-
}}
369+
},
370+
"optional":{
371+
"image3": ("IMAGE",),
372+
"image4": ("IMAGE",),
373+
"image5": ("IMAGE",),
374+
"image6": ("IMAGE",),
375+
}
376+
}
370377

371378
RETURN_TYPES = ("IMAGE",)
372379
FUNCTION = "concanate"
373380
CATEGORY = "utils/image"
374381

375-
def concanate(self, image1, image2, direction):
376-
if image2 is None:
377-
return (image1,)
378-
if image1.shape[1:] != image2.shape[1:]:
379-
image2 = comfy.utils.common_upscale(
380-
image2.movedim(-1, 1), image1.shape[2], image1.shape[1], "bilinear", "center").movedim(1, -1)
381-
if direction == 'right':
382-
row = torch.cat((image1, image2), dim=2)
383-
elif direction == 'down':
384-
row = torch.cat((image1, image2), dim=1)
385-
elif direction == 'left':
386-
row = torch.cat((image2, image1), dim=2)
387-
elif direction == 'up':
388-
row = torch.cat((image2, image1), dim=1)
382+
def concanate(self, image1, image2, image3=None, image4=None, image5=None, image6=None, direction='right'):
383+
images = [image1, image2]
384+
385+
# 添加非空的image3-6到列表中
386+
for img in [image3, image4, image5, image6]:
387+
if img is not None:
388+
images.append(img)
389+
390+
# 如果只有一张图片,直接返回
391+
if len(images) == 1:
392+
return (images[0],)
393+
394+
# 调整所有图片的大小为第一张图片的大小
395+
for i in range(1, len(images)):
396+
if images[i].shape[1:] != images[0].shape[1:]:
397+
images[i] = comfy.utils.common_upscale(
398+
images[i].movedim(-1, 1), images[0].shape[2], images[0].shape[1], "bilinear", "center").movedim(1, -1)
399+
400+
# 根据方向拼接图片
401+
if direction in ['right', 'left']:
402+
row = torch.cat(images if direction == 'right' else [i for i in reversed(images)], dim=2)
403+
elif direction in ['down', 'up']:
404+
row = torch.cat(images if direction == 'down' else [i for i in reversed(images)], dim=1)
405+
389406
return (row,)
390407

391-
392408
class SplitMask:
393409

394410
@classmethod

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-utils-nodes"
33
description = "Nodes:LoadImageWithSwitch, ImageBatchOneOrMore, ModifyTextGender, GenderControlOutput, ImageCompositeMaskedWithSwitch, ColorCorrectOfUtils, SplitMask, MaskFastGrow, CheckpointLoaderSimpleWithSwitch, ImageResizeTo8x, MatchImageRatioToPreset, UpscaleImageWithModelIfNeed, MaskFromFaceModel, MaskCoverFourCorners etc."
4-
version = "1.1.2"
4+
version = "1.1.3"
55
license = { file = "LICENSE" }
66
dependencies = []
77

0 commit comments

Comments
 (0)