update DrawRoundedRectangle node and readme

This commit is contained in:
chflame163
2025-11-07 23:30:43 +08:00
parent de6d880d47
commit 4f4d5cbbe4
5 changed files with 44 additions and 8 deletions
+15
View File
@@ -147,6 +147,7 @@ When this error has occurred, please check the network environment.
<font size="4">**If the dependency package error after updating, please double clicking ```repair_dependency.bat``` (for Official ComfyUI Protable) or ```repair_dependency_aki.bat``` (for ComfyUI-aki-v1.x) in the plugin folder to reinstall the dependency packages. </font><br />
* Commit [DrawRoundedRectangle](#DrawRoundedRectangle) node, used to generate rounded rectangle masks.
* Commit [FluxKontextImageScale](#FluxKontextImageScale) node, based on official node modifications, used to resizes the image to one that is more optimal for flux kontext. For images with different aspect ratio, the scale will be adjusted appropriately to maintain all information.
* Commit [MaskBoxExtend](#MaskBoxExtend) node, used to generate BBOX mask extension range and output as Mask.
* Commit [ColorNegative](#ColorNegative) node, used to invert the color of image.
@@ -2274,6 +2275,20 @@ Node Options:
* grain: Noise intensity.
* invert_mask: Whether to reverse the mask.
### <a id="table1">DrawRoundedRectangle</a>
Generate rounded rectangular borders for the mask.
Node Options:
![image](image/draw_rounded_rectangle_node.jpg)
* size_as<sup>*</sup>: Reference size. It can be an image or a mask.
* rounded_rect_radius: Rounded rectangle radius.
* anti_aliasing: Anti aliasing sampling multiple.
* width: Mask width. If size_as is entered, this setting will be ignored.
* height: Mask height. If size_as is entered, this setting will be ignored.
<sup>*</sup>Only limited to input images and masks. forcing the integration of other types of inputs will result in node errors.
### <a id="table1">MaskPreview</a>
Preview the input mask
+16
View File
@@ -128,6 +128,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
## 更新说明
<font size="4">**如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。
* 添加 [DrawRoundedRectangle](#DrawRoundedRectangle) 节点, 用于生成圆角矩形遮罩。
* 添加 [FluxKontextImageScale](#FluxKontextImageScale) 节点,基于官方节点修改,用于将图像大小调整为更适合FluxKontext的大小。对于非标准宽高比的图像,自动调整比例以保持所有画面信息。
* 添加 [MaskBoxExtend](#MaskBoxExtend) 节点,用于生成遮罩BBOX扩展范围并输出为Mask。
* 添加 [ColorNegative](#ColorNegative)节点,用于将图片颜色反转。
@@ -2036,6 +2037,20 @@ MaskGrow与MaskEdgeShrink效果对比
* grain: 噪声强度。
* invert_mask: 是否反转遮罩。
### <a id="table1">DrawRoundedRectangle</a>
为遮罩生成圆角矩形边框。
节点选项说明:
![image](image/draw_rounded_rectangle_node.jpg)
* size_as<sup>*</sup>: 参考大小。可以是图像image,也可以是遮罩mask。
* rounded_rect_radius: 圆角矩形半径。
* anti_aliasing: 抗锯齿采样倍数。
* width: 遮罩宽度。如果size_as输入,此设置将被忽略。
* height: 遮罩高度。如果size_as输入,此设置将被忽略。
<sup>*</sup>仅限输入image和mask, 如果强制接入其他类型输入,将导致节点错误。
### <a id="table1">MaskPreview</a>
预览mask
![image](image/mask_invert.jpg)
@@ -2045,6 +2060,7 @@ mask反转
![image](image/mask_invert_node.jpg)
# <a id="table1">LayerFilter</a>
![image](image/layerfilter_nodes.jpg)
Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

+8 -3
View File
@@ -14,11 +14,13 @@ class LS_DrawRoundedRectangle:
def INPUT_TYPES(cls):
return {
"required": {
"size_as": (any, {}),
"rounded_rect_radius": ("INT", {"default": 50, "min": 0, "max": 100, "step": 1}),
"anti_aliasing": ("INT", {"default": 2, "min": 0, "max": 16, "step": 1}),
"width": ("INT", {"default": 1024, "min": 8, "max": 1e8, "step": 1}),
"height": ("INT", {"default": 1024, "min": 8, "max": 1e8, "step": 1}),
},
"optional": {
"size_as": (any, {}),
}
}
@@ -27,8 +29,11 @@ class LS_DrawRoundedRectangle:
FUNCTION = 'draw_rounded_rectangle'
CATEGORY = '😺dzNodes/LayerMask'
def draw_rounded_rectangle(self, size_as, rounded_rect_radius, anti_aliasing):
def draw_rounded_rectangle(self, rounded_rect_radius, anti_aliasing, width, height, size_as=None,):
if size_as is None:
target_width, target_height = width, height
else:
if size_as.shape[0] > 0:
_asimage = tensor2pil(size_as[0])
else:
@@ -36,7 +41,7 @@ class LS_DrawRoundedRectangle:
target_width, target_height = _asimage.size
ret_masks = []
mask = Image.new("L", _asimage.size, color='black')
mask = Image.new("L", (target_width, target_height), color='black')
bboxes = [(0, 0, target_width, target_height)]
mask = draw_rounded_rectangle(mask, rounded_rect_radius, bboxes, anti_aliasing)
ret_masks.append(pil2tensor(mask))
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui_layerstyle"
description = "A set of nodes for ComfyUI it generate image like Adobe Photoshop's Layer Style. the Drop Shadow is first completed node, and follow-up work is in progress."
version = "2.0.24"
version = "2.0.26"
license = {text = "MIT License"}
dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "opencv-contrib-python", "pymatting", "timm", "colour-science", "transformers", "blend_modes", "huggingface_hub", "loguru"]