Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kijai committed May 3, 2024
1 parent 28ff367 commit 811baef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#images
"ColorMatch": {"class": ColorMatch, "name": "Color Match"},
"AddLabel": {"class": AddLabel, "name": "Add Label"},
"ImageAndMaskPreview": {"class": ImageAndMaskPreview},
"ImageBatchMulti": {"class": ImageBatchMulti, "name": "Image Batch Multi"},
"ImageBatchTestPattern": {"class": ImageBatchTestPattern, "name": "Image Batch Test Pattern"},
"ImageConcanate": {"class": ImageConcanate, "name": "Image Concanate"},
Expand Down
9 changes: 5 additions & 4 deletions nodes/mask_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ def INPUT_TYPES(s):
"mask": ("MASK",),
}}

RETURN_TYPES = ("MASK","INT", "INT", )
RETURN_NAMES = ("mask", "width", "height",)
RETURN_TYPES = ("MASK","INT", "INT", "INT",)
RETURN_NAMES = ("mask", "width", "height", "count",)
FUNCTION = "getsize"
CATEGORY = "KJNodes/masking"
DESCRIPTION = """
Expand All @@ -843,9 +843,10 @@ def INPUT_TYPES(s):
def getsize(self, mask):
width = mask.shape[2]
height = mask.shape[1]
count = mask.shape[0]
return {"ui": {
"text": [f"{width}x{height}"]},
"result": (mask, width, height)
"text": [f"{count}x{width}x{height}"]},
"result": (mask, width, height, count)
}

class GrowMaskWithBlur:
Expand Down
21 changes: 21 additions & 0 deletions web/js/jsnodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ app.registerExtension({
});
}
break;

case "GetMaskSize":
const onConnectInput = nodeType.prototype.onConnectInput;
nodeType.prototype.onConnectInput = function (targetSlot, type, output, originNode, originSlot) {
const v = onConnectInput?.(this, arguments);
targetSlot.outputs[1]["name"] = "width"
targetSlot.outputs[2]["name"] = "height"
targetSlot.outputs[3]["name"] = "count"
return v;
}
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function(message) {
const r = onExecuted? onExecuted.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 "JoinStringMulti":
nodeType.prototype.onNodeCreated = function () {
this._type = "STRING"
Expand Down

0 comments on commit 811baef

Please sign in to comment.