mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-01-23 13:54:29 +08:00
Rename GetMaskSize to GetMaskSizeAndCount and add image equivalent
This commit is contained in:
parent
811baef799
commit
4d25b205b5
@ -30,7 +30,7 @@ NODE_CONFIG = {
|
||||
"CreateShapeMask": {"class": CreateShapeMask, "name": "Create Shape Mask"},
|
||||
"CreateVoronoiMask": {"class": CreateVoronoiMask, "name": "Create Voronoi Mask"},
|
||||
"CreateMagicMask": {"class": CreateMagicMask, "name": "Create Magic Mask"},
|
||||
"GetMaskSize": {"class": GetMaskSize, "name": "Get Mask Size"},
|
||||
"GetMaskSizeAndCount": {"class": GetMaskSizeAndCount, "name": "Get Mask Size & Count"},
|
||||
"GrowMaskWithBlur": {"class": GrowMaskWithBlur, "name": "Grow Mask With Blur"},
|
||||
"MaskBatchMulti": {"class": MaskBatchMulti, "name": "Mask Batch Multi"},
|
||||
"OffsetMask": {"class": OffsetMask, "name": "Offset Mask"},
|
||||
@ -38,8 +38,9 @@ NODE_CONFIG = {
|
||||
"ResizeMask": {"class": ResizeMask, "name": "Resize Mask"},
|
||||
"RoundMask": {"class": RoundMask, "name": "Round Mask"},
|
||||
#images
|
||||
"ColorMatch": {"class": ColorMatch, "name": "Color Match"},
|
||||
"AddLabel": {"class": AddLabel, "name": "Add Label"},
|
||||
"ColorMatch": {"class": ColorMatch, "name": "Color Match"},
|
||||
"GetImageSizeAndCount": {"class": GetImageSizeAndCount, "name": "Get Image Size & Count"},
|
||||
"ImageAndMaskPreview": {"class": ImageAndMaskPreview},
|
||||
"ImageBatchMulti": {"class": ImageBatchMulti, "name": "Image Batch Multi"},
|
||||
"ImageBatchTestPattern": {"class": ImageBatchTestPattern, "name": "Image Batch Test Pattern"},
|
||||
|
||||
@ -28,7 +28,7 @@ class ImagePass:
|
||||
}
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "passthrough"
|
||||
CATEGORY = "KJNodes/misc"
|
||||
CATEGORY = "KJNodes/image"
|
||||
DESCRIPTION = """
|
||||
Passes the image through without modifying it.
|
||||
"""
|
||||
@ -455,7 +455,33 @@ ComfyUI/custom_nodes/ComfyUI-KJNodes/fonts
|
||||
combined_images = processed_batch
|
||||
|
||||
return (combined_images,)
|
||||
|
||||
class GetImageSizeAndCount:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"image": ("IMAGE",),
|
||||
}}
|
||||
|
||||
RETURN_TYPES = ("IMAGE","INT", "INT", "INT",)
|
||||
RETURN_NAMES = ("image", "width", "height", "count",)
|
||||
FUNCTION = "getsize"
|
||||
CATEGORY = "KJNodes/masking"
|
||||
DESCRIPTION = """
|
||||
Returns the width and height of the image,
|
||||
and passes it through unchanged.
|
||||
|
||||
"""
|
||||
|
||||
def getsize(self, image):
|
||||
width = image.shape[2]
|
||||
height = image.shape[1]
|
||||
count = image.shape[0]
|
||||
return {"ui": {
|
||||
"text": [f"{count}x{width}x{height}"]},
|
||||
"result": (image, width, height, count)
|
||||
}
|
||||
|
||||
class ImageBatchRepeatInterleaving:
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
@ -527,7 +553,7 @@ class ImageNormalize_Neg1_To_1:
|
||||
}}
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "normalize"
|
||||
CATEGORY = "KJNodes/misc"
|
||||
CATEGORY = "KJNodes/image"
|
||||
DESCRIPTION = """
|
||||
Normalize the images to be in the range [-1, 1]
|
||||
"""
|
||||
|
||||
@ -823,7 +823,7 @@ class CreateVoronoiMask:
|
||||
|
||||
return (torch.stack(out, dim=0), 1.0 - torch.stack(out, dim=0),)
|
||||
|
||||
class GetMaskSize:
|
||||
class GetMaskSizeAndCount:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
@ -836,7 +836,7 @@ class GetMaskSize:
|
||||
CATEGORY = "KJNodes/masking"
|
||||
DESCRIPTION = """
|
||||
Returns the width and height of the mask,
|
||||
and passes through the mask unchanged.
|
||||
and passes it through unchanged.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@ -74,18 +74,38 @@ app.registerExtension({
|
||||
}
|
||||
break;
|
||||
|
||||
case "GetMaskSize":
|
||||
const onConnectInput = nodeType.prototype.onConnectInput;
|
||||
case "GetMaskSizeAndCount":
|
||||
const onGetMaskSizeConnectInput = nodeType.prototype.onConnectInput;
|
||||
nodeType.prototype.onConnectInput = function (targetSlot, type, output, originNode, originSlot) {
|
||||
const v = onConnectInput?.(this, arguments);
|
||||
const v = onGetMaskSizeConnectInput?.(this, arguments);
|
||||
targetSlot.outputs[1]["name"] = "width"
|
||||
targetSlot.outputs[2]["name"] = "height"
|
||||
targetSlot.outputs[3]["name"] = "count"
|
||||
return v;
|
||||
}
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
const onGetMaskSizeExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function(message) {
|
||||
const r = onExecuted? onExecuted.apply(this,arguments): undefined
|
||||
const r = onGetMaskSizeExecuted? onGetMaskSizeExecuted.apply(this,arguments): undefined
|
||||
let values = message["text"].toString().split('x').map(Number);
|
||||
this.outputs[1]["name"] = values[1] + " width"
|
||||
this.outputs[2]["name"] = values[2] + " height"
|
||||
this.outputs[3]["name"] = values[0] + " count"
|
||||
return r
|
||||
}
|
||||
break;
|
||||
|
||||
case "GetImageSizeAndCount":
|
||||
const onGetImageSizeConnectInput = nodeType.prototype.onConnectInput;
|
||||
nodeType.prototype.onConnectInput = function (targetSlot, type, output, originNode, originSlot) {
|
||||
const v = onGetImageSizeConnectInput?.(this, arguments);
|
||||
targetSlot.outputs[1]["name"] = "width"
|
||||
targetSlot.outputs[2]["name"] = "height"
|
||||
targetSlot.outputs[3]["name"] = "count"
|
||||
return v;
|
||||
}
|
||||
const onGetImageSizeExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function(message) {
|
||||
const r = onGetImageSizeExecuted? onGetImageSizeExecuted.apply(this,arguments): undefined
|
||||
let values = message["text"].toString().split('x').map(Number);
|
||||
this.outputs[1]["name"] = values[1] + " width"
|
||||
this.outputs[2]["name"] = values[2] + " height"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user