mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-01-24 13:14:32 +08:00
ImageAddMulti
This commit is contained in:
parent
5631cd0146
commit
d24d1c64d2
@ -45,6 +45,7 @@ NODE_CONFIG = {
|
||||
"GetImageRangeFromBatch": {"class": GetImageRangeFromBatch, "name": "Get Image Range From Batch"},
|
||||
"GetImageSizeAndCount": {"class": GetImageSizeAndCount, "name": "Get Image Size & Count"},
|
||||
"ImageAndMaskPreview": {"class": ImageAndMaskPreview},
|
||||
"ImageAddMulti": {"class": ImageAddMulti, "name": "Image Add Multi"},
|
||||
"ImageBatchMulti": {"class": ImageBatchMulti, "name": "Image Batch Multi"},
|
||||
"ImageBatchRepeatInterleaving": {"class": ImageBatchRepeatInterleaving},
|
||||
"ImageBatchTestPattern": {"class": ImageBatchTestPattern, "name": "Image Batch Test Pattern"},
|
||||
|
||||
@ -1134,6 +1134,50 @@ with the **inputcount** and clicking update.
|
||||
for c in range(1, inputcount):
|
||||
new_image = kwargs[f"image_{c + 1}"]
|
||||
image, = image_batch_node.batch(image, new_image)
|
||||
return (image,)
|
||||
|
||||
class ImageAddMulti:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"inputcount": ("INT", {"default": 2, "min": 2, "max": 1000, "step": 1}),
|
||||
"image_1": ("IMAGE", ),
|
||||
"image_2": ("IMAGE", ),
|
||||
"blending": (
|
||||
[ 'add',
|
||||
'subtract',
|
||||
'multiply',
|
||||
'difference',
|
||||
],
|
||||
{
|
||||
"default": 'add'
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("images",)
|
||||
FUNCTION = "add"
|
||||
CATEGORY = "KJNodes/image"
|
||||
DESCRIPTION = """
|
||||
Add blends multiple images together.
|
||||
You can set how many inputs the node has,
|
||||
with the **inputcount** and clicking update.
|
||||
"""
|
||||
|
||||
def add(self, inputcount, blending, **kwargs):
|
||||
image = kwargs["image_1"]
|
||||
for c in range(1, inputcount):
|
||||
new_image = kwargs[f"image_{c + 1}"]
|
||||
if blending == "add":
|
||||
image = torch.add(image * 0.5, new_image * 0.5)
|
||||
elif blending == "subtract":
|
||||
image = torch.sub(image * 0.5, new_image * 0.5)
|
||||
elif blending == "multiply":
|
||||
image = torch.mul(image * 0.5, new_image * 0.5)
|
||||
elif blending == "difference":
|
||||
image = torch.sub(image, new_image)
|
||||
return (image,)
|
||||
|
||||
class PreviewAnimation:
|
||||
|
||||
@ -30,6 +30,7 @@ app.registerExtension({
|
||||
}
|
||||
break;
|
||||
case "ImageBatchMulti":
|
||||
case "ImageAddMulti":
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
this._type = "IMAGE"
|
||||
this.inputs_offset = nodeData.name.includes("selective")?1:0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user