Skip to content

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

License

Notifications You must be signed in to change notification settings

chflame163/ComfyUI_LayerStyle

Repository files navigation

ComfyUI Layer Style

中文说明点这里

如果您有定制节点、定制工作流业务,请联系email chflame@163.com.

For business cooperation, please contact email chflame@163.com.

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

It migrate some basic functions of PhotoShop to ComfyUI, aiming to centralize the workflow and reduce the frequency of software switching.

image
*this workflow (title_example_workflow.json) is in the workflow directory.

Example workflow

Some JSON workflow files in the workflow directory, That's examples of how these nodes can be used in ComfyUI.

How to install

  • Recommended use ComfyUI Manager for installation.

  • Or open the cmd window in the plugin directory of ComfyUI, like ComfyUI\custom_nodes,type

git clone https://github.com/chflame163/ComfyUI_LayerStyle.git
  • Or download the zip file and extracted, copy the resulting folder to ComfyUI\custom_ Nodes

  • Install dependency packages, open the cmd window in the ComfyUI_LayerStyle plugin directory like
    ComfyUI\custom_ Nodes\ComfyUI_LayerStyle and enter the following command:

..\..\..\python_embeded\python.exe -m pip install -r requirements.txt
  • Restart ComfyUI.

Common Issues

If the node cannot load properly or there are errors during use, please check the error message in the ComfyUI terminal window. The following are common errors and their solutions.

Cannot import name 'guidedFilter' from 'cv2.ximgproc'

This error is caused by incorrect version of the opencv-contrib-python package,or this package is overwriteen by other opencv packages.

NameError: name 'guidedFilter' is not defined

The reason for the problem is the same as above.

Cannot import name 'VitMatteImageProcessor' from 'transformers'

This error is caused by the low version of transformers package.

insightface Loading very slow

This error is caused by the low version of protobuf package.

For the issues with the above three dependency packages, please double click repair_dependency.bat (for Official ComfyUI Protable) or repair_dependency_aki.bat (for ComfyUI-aki-v1.x) in the plugin folder to automatically fix them.

ValueError: Trimap did not contain foreground values (xxxx...)

This error is caused by the mask area being too large or too small when using the PyMatting method to handle the mask edges.

Solution:

  • Please adjust the parameters to change the effective area of the mask. Or use other methods to handle the edges.

Requests.exceptions.ProxyError: HTTPSConnectionPool(xxxx...)

When this error has occurred, please check the network environment.

Update

**If the dependency package error after updating, please reinstall the relevant dependency packages.

  • Commit MaskByColor node, Generate a mask based on the selected color.
  • Commit LoadPSD node, It read the psd format, and output layer images.
  • Commit SegformerB2ClothesUltra node, it used to segment character clothing. The model segmentation code is fromStartHua, thanks to the original author.
  • SaveImagePlus node adds the output workflow to the json function, supports %date and %time to embeddint date or time to path and filename, and adds the preview switch.
  • Commit SaveImagePlus node,It can customize the directory where the picture is saved, add a timestamp to the file name, select the save format, set the image compression rate, set whether to save the workflow, and optionally add invisible watermarks to the picture.
  • Commit AddBlindWaterMark, ShowBlindWaterMark nodes, Add invisible watermark and decoded watermark to the picture. Commit CreateQRCode, DecodeQRCode nodes, It can generate two-dimensional code pictures and decode two-dimensional codes.
  • ImageScaleRestoreV2, ImageScaleByAspectRatioV2, ImageAutoCropV2 nodes add options for width and height, which can specify width or height as fixed values.
  • Commit PurgeVRAM node, Clean up VRAM an RAM.
  • Commit AutoAdjust node, it can automatically adjust image contrast and white balance.
  • Commit RGBValue node to output the color value as a single decimal value of R, G, B. This idea is from vxinhao, Thanks.
  • Commit seed node to output the seed value. The ImageMaskScaleAs, ImageScaleBySpectRatio, ImageScaleBySpectRatioV2, ImageScaleRestore, ImageScaleRestoreV2 nodes increase width, height output.
  • Commit Levels node, it can achieve the same color levels adjustment function as Photoshop.Sharp&Soft add the "None" option.
  • Commit BlendIfMask node, This node cooperates with ImgaeBlendV2 or ImageBlendAdvanceV2 to achieve the same Blend If function as Photoshop.
  • Commit ColorTemperature and ColorBalance nodes, used to adjust the color temperature and color balance of the picture.
  • Add new types of Blend Mode V2 between images. now supports up to 30 blend modes. The new blend mode is available for all V2 versions that support mixed mode nodes, including ImageBlend V2, ImageBlendAdvance V2, DropShadow V2, InnerShadow V2, OuterGlow V2, InnerGlow V2, Stroke V2, ColorOverlay V2, GradientOverlay V2.
    Part of the code for BlendMode V2 is from Virtuoso Nodes for ComfyUI. Thanks to the original authors.
  • Commit YoloV8Detect node.
  • Commit QWenImage2Prompt node, this node is repackage of the ComfyUI_VLM_nodes's UForm-Gen2 Qwen Node, thanks to the original author.
  • Commit BooleanOperator, NumberCalculator, TextBox, Integer, Float, Booleannodes. These nodes can perform mathematical and logical operations.
  • Commit ExtendCanvasV2 node,support color value input.
  • Commit AutoBrightness node,it can automatically adjust the brightness of image.
  • CreateGradientMask node add center option.
  • Commit GetColorToneV2 node, can select the main and average colors for the background or body.
  • Commit ImageRewardFilter node, can filter out poor quality pictures.
  • Ultra nodes add VITMatte(local) method, You can choose this method to avoid accessing huggingface.co if you have already downloaded the model before.
  • Commit HDR Effect node,it enhances the dynamic range and visual appeal of input images. this node is repackage of HDR Effects (SuperBeasts.AI).
  • Commit CropBoxResolve node.
  • Commit BiRefNetUltra node, it using the BiRefNet model to remove background has better recognition ability and ultra-high edge details.
  • Commit ImageAutoCropV2 node, it can choose not to remove the background, support mask input, and scale by long or short side size.
  • Commit ImageHub node, supports up to 9 sets of Image and Mask switching output, and supports random output.
  • Commit TextJoin node.
  • Commit PromptEmbellish node. it output polished prompt words, and support inputting images as references.
  • Ultra nodes have been fully upgraded to V2 version, with the addition of VITMatte edge processing method, which is suitable for handling semi transparent areas. Include MaskEdgeUltraDetailV2, SegmentAnythingUltraV2, RmBgUltraV2 and PersonMaskUltraV2 nodes.
  • Commit Color of Shadow & Highlight node, it can adjust the color of the dark and bright parts separately. Commit Shadow & Highlight Mask node, it can output mask for dark and bright areas.
  • Commit CropByMaskV2 node, On the basis of the original node, it supports crop_box input, making it convenient to cut layers of the same size.
  • Commit SimpleTextImage node, it generate simple typesetting images and masks from text. This node references some of the functionalities and code of ZHO-ZHO-ZHO/ComfyUI-Text_Image-Composite.
  • Commit PromptTagger node,Inference the prompts based on the image. and it can replace key word for the prompt(need apply for Google Studio API key). Upgrade ColorImageV2 and GradientImageV2,support user customize preset sizes and size_as input.
  • Commit LaMa node, it can erase objects from the image based on the mask. this node is repackage of IOPaint.
  • Commit ImageRemoveAlpha and ImageCombineAlpha nodes, alpha channel of the image can be removed or merged.
  • Commit ImageScaleRestoreV2 and ImageScaleByAspectRatioV2 nodes, supports scaling images to specified long or short edge sizes.
  • Commit PersonMaskUltra node, Generate masks for portrait's face, hair, body skin, clothing, or accessories. the model code for this node comes from a-person-mask-generator.
  • Commit LightLeak node, this filter simulate the light leakage effect of the film.
  • Commit Film node, this filter simulate the grain, dark edge, and blurred edge of the film, support input depth map to simulate defocus. it is reorganize and encapsulate of digitaljohn/comfyui-propost.
  • Commit ImageAutoCrop node, which is designed to generate image materials for training models.
  • Commit ImageScaleByAspectRatio node, it can be scaled image or mask according to frame ratio.
  • Fix the bug of color gradation in LUT Apply node rendering, and this node now support for log color space. *Please load the dedicated log lut file for the log color space image.
  • Commit CreateGradientMask node. Commit LayerImageTransform and LayerMaskTransform nodes.
  • Commit MaskEdgeUltraDetail node, it process rough masks to ultra fine edges.Commit Exposure node.
  • Commit Sharp & Soft node, it can enhance or smooth out image details. Commit MaskByDifferent node, it compare two images and output a Mask. Commit SegmentAnythingUltra node, Improve the quality of mask edges. *If SegmentAnything is not installed, you will need to manually download the model.
  • All nodes have fully supported batch images, providing convenience for video creation. (The CropByMask node only supports cuts of the same size. if a batch mask_for_crop inputted, the data from the first sheet will be used.)
  • Commit RemBgUltra and PixelSpread nodes significantly improved mask quality. *RemBgUltra requires manual model download.
  • Commit TextImage node, it generate text images and masks.
  • Add new types of blend mode between images. now supports up to 19 blend modes. add color_burn, color_dodge, linear_burn, linear_dodge, overlay, soft_light, hard_light, vivid_light, pin_light, linear_light and hard_mix. The newly added blend mode is applicable to all nodes that support blend mode.
  • Commit ColorMap filter node to create a pseudo color heatmap effect.
  • Commit WaterColor and SkinBeauty nodes。These are image filters that generate watercolor and skin smoothness effects.
  • Commit ImageShift node to shift the image and output a displacement seam mask, making it convenient to create continuous textures.
  • Commit ImageMaskScaleAs node to adjust the image or mask size based on the reference image.
  • Commit ImageScaleRestore node to work with CropByMask for local upscale and repair works.
  • Commit CropByMask and RestoreCropBox nodes. The combination of these two can partially crop and redraw the image before restoring it.
  • Commit ColorAdapter node, that can automatically adjust the color tone of the image.
  • Commit MaskStroke node, it can generate mask contour strokes.
  • Add LayerColor node group, used to adjust image color. it include LUT Apply, Gamma, Brightness & Contrast, RGB, YUV, LAB adn HSV.
  • Commit ImageChannelSplit and ImageChannelMerge nodes.
  • Commit MaskMotionBlur node.
  • Commit SoftLight node.
  • Commit ChannelShake node, that is filter, can produce channel dislocation effect similar like Tiktok logo.
  • Commit MaskGradient node, can create a gradient in the mask.
  • Commit GetColorTone node, can obtain the main color or average color of the image. Commit MaskGrow and MaskEdgeShrink nodes.
  • Commit MaskBoxDetect node, which can automatically detect the position through the mask and output it to the composite node. Commit XY to Percent node to convert absolute coordinates to percent coordinates. Commit GaussianBlur node. Commit GetImageSize node.
  • Commit ExtendCanvas node.
  • Commit ImageBlendAdvance node. This node allows for the synthesis of background images and layers of different sizes, providing a more free synthesis experience. Commit PrintInfo node as a workflow debugging aid.
  • Commit ColorImage and GradientImage nodes, Used to generate solid and gradient color images.
  • Commit GradientOverlay and ColorOverlay nodes. Add invalid mask input judgment and ignore it when invalid mask is input.
  • Commit InnerGlow, InnerShadow and MotionBlur nodes.
  • Renaming all completed nodes, the nodes are divided into 4 groups:LayerStyle, LayerMask, LayerUtility, LayerFilter. workflows containing old version nodes need to be manually replaced with new version nodes.
  • OuterGlow node has undergone significant modifications by adding options for brightness, light_color, and glow_color.
  • Commit MaskInvert node.
  • Commit ColorPick node.
  • Commit Stroke node.
  • Commit MaskPreview node.
  • Commit ImageOpacity node.
  • The layer_mask is not a mandatory input now. it is allowed to use layers and masks with different shapes, but the size must be consistent.
  • Commit ImageBlend node.
  • Commit OuterGlow node.
  • Commit DropShadow node.

Description

Nodes are divided into 5 groups according to their functions: LayerStyle, LayerColor, LayerMask, LayerUtility and LayerFilter.

  • LayerStyle nodes provides layer styles that mimic Adobe Photoshop. image
  • LayerColor node group provides color adjustment functionality. image
  • LayerMask nodes provides mask assistance tools. image
  • LayerUtility nodes provides auxiliary nodes related to layer composit tools and workflows. image
  • LayerFilter nodes provides image effect filters. image

image
image

Generate shadow image

Node options: image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image, shadows are generated according to their shape.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of shadows.
  • opacity: Opacity of shadow.
  • distance_x: Horizontal offset of shadow.
  • distance_y: Vertical offset of shadow.
  • grow: Shadow expansion amplitude.
  • blur: Shadow blur level.
  • shadow_color4: Shadow color.
  • note

Generate outer glow image

Node options: image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image, grow are generated according to their shape.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of glow.
  • opacity: Opacity of glow.
  • brightness: Luminance of light.
  • glow_range: range of glow.
  • blur:blur of glow.
  • light_color4: Center part color of glow.
  • glow_color4: Edge part color of glow.
  • note

Generate inner shadow image

Node options: image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image, shadows are generated according to their shape.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of shadows.
  • opacity: Opacity of shadow.
  • distance_x: Horizontal offset of shadow.
  • distance_y: Vertical offset of shadow.
  • grow: Shadow expansion amplitude.
  • blur: Shadow blur level.
  • shadow_color4: Shadow color.
  • note

Generate inner glow image

Node options:
image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image, grow are generated according to their shape.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of glow.
  • opacity: Opacity of glow.
  • brightness: Luminance of light.
  • glow_range: range of glow.
  • blur:blur of glow.
  • light_color4: Center part color of glow.
  • glow_color4: Edge part color of glow.
  • note

Generate a stroke of layer。 image

Node options:
image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image, stroke are generated according to their shape.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of stroke.
  • opacity: Opacity of stroke.
  • stroke_grow: Stroke expansion/contraction amplitude, positive values indicate expansion and negative values indicate contraction.
  • stroke_width: Stroke width.
  • blur: Blur of stroke.
  • stroke_color4: Stroke color, described in hexadecimal RGB format.
  • note

Generate gradient overlay image

Node options:

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of gradient.
  • opacity: Opacity of stroke.
  • start_color: Color at the beginning of the gradient.
  • start_alpha: Transparency at the beginning of the gradient.
  • end_color: Color at the end of the gradient.
  • end_alpha: Transparency at the end of the gradient.
  • angle: Gradient rotation angle.
  • note

Generate color overlay image

Node options: image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode of color.
  • opacity: Opacity of stroke.
  • color: Color of overlay.
  • note

image
image

LUT Apply

Apply LUT to the image. only supports .cube format.

Node options:
image

  • LUT*: Here is a list of available. cube files in the LUT folder, and the selected LUT files will be applied to the image.
  • color_space: For regular image, please select linear, for image in the log color space, please select log.

*LUT folder is defined in resource_dir.ini, this file is located in the root directory of the plug-in, and the default name is resource_dir.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open the text editing software and find the line starting with "LUT_dir=", after "=", enter the custom folder path name. all .cube files in this folder will be collected and displayed in the node list during ComfyUI initialization. If the folder set in ini is invalid, the LUT folder that comes with the plugin will be enabled.

Automatically adjust the brightness, contrast, and white balance of the image. Provide some manual adjustment options to compensate for the shortcomings of automatic adjustment. image

Node Options:
image

  • strength: Strength of adjust. The larger the value, the greater the difference from the original image.
  • brightness: Manual adjustment of brightness.
  • contrast: Manual adjustment of contrast.
  • saturation: Manual adjustment of saturation.
  • red: Manual adjustment of the red channel.
  • green: Manual adjustment of the green channel.
  • blue: Manual adjustment of the blue channel.

Automatically adjust too dark or too bright image to moderate brightness, and support mask input. When mask input, only the content of the mask part is used as the data source of the automatic brightness. The output is still the whole adjusted image. image

Node options:
image

  • strength: Automatically adjust the intensity of the brightness. The larger the value, the more biased towards the middle value, the greater the difference from the original picture.
  • saturation: Color saturation. Changes in brightness usually result in changes in color saturation, where appropriate compensation can be adjusted.

Auto adjust the color tone of the image to resemble the reference image. image

Node options:
image

  • opacity: The opacity of an image after adjusting its color tone.

Change the exposure of the image. image

Color of Shadow & Highlight

Adjust the color of the dark and bright parts of the image. image

Node options:
image

  • image: The input image.
  • mask: Optional input. if there is input, only the colors within the mask range will be adjusted.
  • shadow_brightness: The brightness of the dark area.
  • shadow_saturation: The color saturation in the dark area.
  • shadow_hue: The color hue in the dark area.
  • shadow_level_offset: The offset of values in the dark area, where larger values bring more areas closer to the bright into the dark area.
  • shadow_range: The transitional range of the dark area.
  • highlight_brightness: The brightness of the highlight area.
  • highlight_saturation: The color saturation in the highlight area.
  • highlight_hue: The color hue in the highlight area.
  • highlight_level_offset: The offset of values in the highlight area, where larger values bring more areas closer to the dark into the highlight area.
  • highlight_range: The transitional range of the highlight area.

Node option:

  • exposure: Exposure value. Higher values indicate brighter image.

image
Change the color temperature of the image.

Node Options:
image

  • temperature: Color temperature value. Range between-100 and 100. The higher the value, the higher the color temperature (bluer); The lower the color temperature, the lower the color temperature (yellowish).

image
Change the levels of image.

Node Options:
image

  • channel: Select the channel you want to adjust. Available in RGB, red, green, blue.
  • black_point*: Input black point value. Value range 0-255, default 0.
  • white_point*: Input white point value. Value range 0-255, default 255.
  • gray_point: Input grey point values. Value range 0.01-9.99, default 1.
  • output_black_point*: Output black point value. Value range 0-255, default 0.
  • output_white_point*: Output white point value. Value range 0-255, default 255.

*If the black_point or output_black_point value is greater than white_point or output_white_point, the two values are swapped, with the larger value used as white_point and the smaller value used as black_point.

image
Change the color balance of an image.

Node Options:
image

  • cyan_red: Cyan-Red balance. negative values are leaning cyan, positive values are leaning red.
  • magenta_green: Megenta-Green balance. negative values are leaning megenta, positive values are leaning green.
  • yellow_blue: Yellow-Blue balance. negative values are leaning yellow, positive values are leaning blue.

Change the gamma value of the image.

Node options:
image

  • gamma: Value of the Gamma.

Brightness & Contrast

Change the brightness, contrast, and saturation of the image.

Node options:
image

  • brightness: Value of brightness.
  • contrast: Value of contrast.
  • saturation: Value of saturation.

Adjust the RGB channels of the image.

Node options:
image

  • R: R channel.
  • G: G channel.
  • B: B channel.

Adjust the YUV channels of the image.

Node options:
image

  • Y: Y channel.
  • U: U channel.
  • V: V channel.

Adjust the LAB channels of the image.

Node options:
image

  • L: L channel.
  • A: A channel.
  • B: B channel.

Adjust the HSV channels of the image.

Node options:
image

  • H: H channel.
  • S: S channel.
  • V: V channel.

image

Used for compositing layers, allowing for compositing layer images of different sizes on the background image, and setting positions and transformations. multiple mixing modes are available for selection, and transparency can be set.

The node provide layer transformation_methods and anti_aliasing options. helps improve the quality of synthesized images.

The node provides mask output that can be used for subsequent workflows. image

Node options:
image

  • background_image: The background image.
  • layer_image5: Layer image for composite.
  • layer_mask2,5: Mask for layer_image.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode.
  • opacity: Opacity of blend.
  • x_percent: Horizontal position of the layer on the background image, expressed as a percentage, with 0 on the far left and 100 on the far right. It can be less than 0 or more than 100, indicating that some of the layer's content is outside the screen.
  • y_percent: Vertical position of the layer on the background image, expressed as a percentage, with 0 on the top and 100 on the bottom. For example, setting it to 50 indicates vertical center, 20 indicates upper center, and 80 indicates lower center.
  • mirror: Mirror flipping. Provide two flipping modes, horizontal flipping and vertical flipping.
  • scale: Layer magnification, 1.0 represents the original size.
  • aspect_ratio: Layer aspect ratio. 1.0 is the original ratio, a value greater than this indicates elongation, and a value less than this indicates flattening.
  • rotate: Layer rotation degree.
  • Sampling methods for layer enlargement and rotation, including lanczos, bicubic, hamming, bilinear, box and nearest. Different sampling methods can affect the image quality and processing time of the synthesized image.
  • anti_aliasing: Anti aliasing, ranging from 0 to 16, the larger the value, the less obvious the aliasing. An excessively high value will significantly reduce the processing speed of the node.
  • note

Crop the image according to the mask range, and set the size of the surrounding borders to be retained. This node can be used in conjunction with the RestoreCropBox and ImageScaleRestore nodes to crop and modify upscale parts of image, and then paste them back in place. image

Node options:
image

  • image5: The input image.
  • mask_for_crop5: Mask of the image, it will automatically be cut according to the mask range.
  • invert_mask: Whether to reverse the mask.
  • detect: Detection method, min_bounding_rect is the minimum bounding rectangle of block shape, max_inscribed_rect is the maximum inscribed rectangle of block shape, and mask-area is the effective area for masking pixels.
  • top_reserve: Cut the top to preserve size.
  • bottom_reserve: Cut the bottom to preserve size.
  • left_reserve: Cut the left to preserve size.
  • right_reserve: Cut the right to preserve size.
  • note

Output:

  • croped_image: The image after crop.
  • croped_mask: The mask after crop.
  • crop_box: The trimmed box data is used when restoring the RestoreCropBox node.
  • box_preview: Preview image of cutting position, red represents the detected range, and green represents the cutting range after adding the reserved border.

The V2 upgraded version of CropByMask. Supports crop_box input, making it easy to cut layers of the same size.

The following changes have been made based on CropByMask: image

  • The input mask_for_crop reanme to mask
  • Add optional inputs to the crop_box. If there are inputs here, mask detection will be ignored and this data will be directly used for cropping.

Restore the cropped image to the original image by CropByMask.

Node options:
image

  • background_image: The original image before cutting.
  • croped_image5: The cropped image. If the middle is enlarged, the size needs to be restored before restoration.
  • croped_mask5: The cut mask.
  • crop_box: Box data during cutting.
  • invert_mask: Whether to reverse the mask.
  • note

Parsing the corp_box to x , y , width , height . image

Image scaling. when this node is used in pairs, the image can be automatically restored to its original size on the second node. image

Node options:
image

  • image5: The input image.
  • mask2,5: Mask of image.
  • original_size: Optional input, used to restore the image to its original size.
  • scale: Scale ratio. when the original_size have input, or scale_ by_longest_side is set to True, this setting will be ignored.
  • scale_by_longest_side: Allow scaling by long edge size.
  • longest_side: When the scale_by_longest_side is set to True, this will be used this value to the long edge of the image. when the original_size have input, this setting will be ignored.

Outputs:

  • image: The scaled image.
  • mask: If have mask input, the scaled mask will be output.
  • original_size: The original size data of the image is used for subsequent node recovery.
  • width: The output image's width.
  • height: The output image's height.

The V2 upgraded version of ImageScaleRestore.

Node options:
image
The following changes have been made based on ImageScaleRestore:

  • scale_by: Allow scaling by specified dimensions for longest, shortest, width, or height.
  • scale_by_length: The value here is used as scale_by to specify the length of the edge.

Scale the image or mask to the size of the reference image (or reference mask). image

Node options: image

  • scale_as*: Reference size. It can be an image or a mask.
  • image: Image to be scaled. this option is optional input. if there is no input, a black image will be output.
  • mask: Mask to be scaled. this option is optional input. if there is no input, a black mask will be output.
  • fit: Scale aspect ratio mode. when the width to height ratio of the original image does not match the scaled size, there are three modes to choose from, The letterbox mode retains the complete frame and fills in the blank spaces with black; The crop mode retains the complete short edge, and any excess of the long edge will be cut off; The fill mode does not maintain frame ratio and fills the screen with width and height.
  • method: Scaling sampling methods, including lanczos, bicubic, hamming, bilinear, box, and nearest.

*Only limited to input images and masks. forcing the integration of other types of inputs will result in node errors.

Outputs:

  • image: If there is an image input, the scaled image will be output.
  • mask: If there is a mask input, the scaled mask will be output.
  • original_size: The original size data of the image is used for subsequent node recovery.
  • width: The output image's width.
  • height: The output image's height.

Scale the image or mask by aspect ratio. the scaled size can be rounded to a multiple of 8 or 16, and can be scaled to the long side size. image

Node options:
image

  • aspect_ratio: Here are several common frame ratios provided. alternatively, you can choose "original" to keep original ratio or customize the ratio using "custom".
  • proportional_width: Proportional width. if the aspect ratio option is not "custom", this setting will be ignored.
  • proportional_height: Proportional height. if the aspect ratio option is not "custom", this setting will be ignored.
  • fit: Scale aspect ratio mode. when the width to height ratio of the original image does not match the scaled size, there are three modes to choose from, The letterbox mode retains the complete frame and fills in the blank spaces with black; The crop mode retains the complete short edge, and any excess of the long edge will be cut off; The fill mode does not maintain frame ratio and fills the screen with width and height.
  • method: Scaling sampling methods, including lanczos, bicubic, hamming, bilinear, box, and nearest.
  • round_to_multiple: Round multiples. for example, setting it to 8 will force the width and height to be multiples of 8.
  • scale_by_longest_side: Allow scaling by long edge size.
  • longest_side: When the scale_by_longest_side is set to True, this will be used this value to the long edge of the image. when the original_size have input, this setting will be ignored.

Outputs:

  • image: If have image input, the scaled image will be output.
  • mask: If have mask input, the scaled mask will be output.
  • original_size: The original size data of the image is used for subsequent node recovery.
  • width: The output image's width.
  • height: The output image's height.

V2 Upgraded Version of ImageScaleByAspectRatio

Node options:
image
The following changes have been made based on ImageScaleByAspectRatio:

  • scale_by: Allow scaling by specified dimensions for longest, shortest, width, or height.
  • scale_by_length: The value here is used as scale_by to specify the length of the edge.

Inference the prompts based on the image. this node is repackage of the ComfyUI_VLM_nodes's UForm-Gen2 Qwen Node, thanks to the original author. Download model files from huggingface or Baidu Netdisk to ComfyUI/models/LLavacheckpoints/files_for_uform_gen2_qwen folder.

image

Node Options:

  • question: Prompt of UForm-Gen-QWen model.

Inference the prompts based on the image. it can replace key word for the prompt. This node currently uses Google Gemini API as the backend service. Please ensure that the network environment can use Gemini normally. Please apply for your API key on Google AI Studio, And fill it in api_key.ini, this file is located in the root directory of the plug-in, and the default name is api_key.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open it using text editing software, fill in your API key after google_api_key= and save it. image

Node options:
image

  • api: The Api used. At present, there is only one option, "gemini-pro-vision".
  • token_limit: The maximum token limit for generating prompt words.
  • exclude_word: Keywords that need to be excluded.
  • replace_with_word: That word will replace the exclude_word.

Enter simple prompt words, output polished prompt words, and support inputting images as references. This node currently uses Google Gemini API as the backend service. Please ensure that the network environment can use Gemini normally. Please apply for your API key on Google AI Studio, And fill it in api_key.ini, this file is located in the root directory of the plug-in, and the default name is api_key.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open it using text editing software, fill in your API key after google_api_key= and save it. image

Node options:
image

  • image: Optional, input image as a reference for prompt words.
  • api: The Api used. At present, there is only one option, "google-gemini".
  • token_limit: The maximum token limit for generating prompt words.
  • discribe: Enter a simple description here. supports Chinese text input.

Shift the image. this node supports the output of displacement seam masks, making it convenient to create continuous textures. image

Node options:
image

  • image5: The input image.
  • mask2,5: The mask of image.
  • shift_x: Horizontal distance of shift.
  • shift_y: Vertical distance of shift.
  • cyclic: Is the part of displacement that is out of bounds cyclic.
  • background_color: Background color. if cyclic is set to False, the setting here will be used as the background color.
  • border_mask_width: Border mask width.
  • border_mask_blur: Border mask blur.
  • note

A simple node for composit layer image and background image, multiple blend modes are available for option, and transparency can be set. image

Node options: image

  • background_image1: The background image.
  • layer_image1: Layer image for composite.
  • layer_mask1,2: Mask for layer_image.
  • invert_mask: Whether to reverse the mask.
  • blend_mode3: Blending mode.
  • opacity: Opacity of blend.
  • note

Adjust image opacity image

Node option:

  • image5: Image input, supporting RGB and RGBA. if is RGB, the alpha channel of the entire image will be automatically added.
  • mask2,5 : Mask input.
  • invert_mask: Whether to reverse the mask.
  • opacity: Opacity of image.
  • note

Modify web extensions from mtb nodes. Select colors on the color palette and output RGB values, thanks to the original author. image

Node options:

  • mode: The output format is available in hexadecimal (HEX) and decimal (DEC).

Output type:

  • value: String format.

Output the color value as a single R, G, B three decimal values. Supports HEX and DEC formats for ColorPicker node output.

image

Node Options:

  • color_value: Supports hexadecimal (HEX) or decimal (DEC) color values and should be of string or tuple type. Forcing in other types will result in an error.

Obtain the main color or average color from the image and output RGB values. image

Node options: image

  • mode: There are two modes to choose from, with the main color and average color.

Output type:

  • RGB color in HEX: The RGB color described by hexadecimal RGB format, like '#FA3D86'.
  • HSV color in list: The HSV color described by python's list data format.

V2 upgrade of GetColorTone. You can specify the dominant or average color to get the body or background. image

The following changes have been made on the basis of GetColorTong: image

  • color_of: Provides three options, entire, background, and subject, to select the color of the entire picture, background, or body, respectively.
  • remove_background_method: There are two methods of background recognition: BiRefNet and RMBG V1.4.
  • invert_mask: Whether to reverse the mask.
  • mask_grow: Mask expansion. For subject, a larger value brings the obtained color closer to the color at the center of the body.

Output:

  • image: Solid color picture output, the size is the same as the input picture.

Extend the canvas image

Node options: image

  • invert_mask: Whether to reverse the mask.
  • top: Top extension value.
  • bottom: Bottom extension value.
  • left: Left extension value.
  • right: Right extension value.
  • color; Color of canvas.

V2 upgrade to ExtendCanvas.

Based on ExtendCanvas, color is modified to be a string type, and it supports external ColorPicker input. image

XY to Percent

image
Convert absolute coordinates to percentage coordinates.

image
Node options:

  • x: Value of X.
  • y: Value of Y.

image
This node is used to transform layer_image separately, which can change size, rotation, aspect ratio, and mirror flip without changing the image size.

image
Node options:

  • x: Value of X.
  • y: Value of Y.
  • mirror: Mirror flipping. Provide two flipping modes, horizontal flipping and vertical flipping.
  • scale: Layer magnification, 1.0 represents the original size.
  • aspect_ratio: Layer aspect ratio. 1.0 is the original ratio, a value greater than this indicates elongation, and a value less than this indicates flattening.
  • rotate: Layer rotation degree.
  • Sampling methods for layer enlargement and rotation, including lanczos, bicubic, hamming, bilinear, box and nearest. Different sampling methods can affect the image quality and processing time of the synthesized image.
  • anti_aliasing: Anti aliasing, ranging from 0 to 16, the larger the value, the less obvious the aliasing. An excessively high value will significantly reduce the processing speed of the node.

Similar to LayerImageTransform node, this node is used to transform the layer_mask separately, which can scale, rotate, change aspect ratio, and mirror flip without changing the mask size.

image
Node options:

  • x: Value of X.
  • y: Value of Y.
  • mirror: Mirror flipping. Provide two flipping modes, horizontal flipping and vertical flipping.
  • scale: Layer magnification, 1.0 represents the original size.
  • aspect_ratio: Layer aspect ratio. 1.0 is the original ratio, a value greater than this indicates elongation, and a value less than this indicates flattening.
  • rotate: Layer rotation degree.
  • Sampling methods for layer enlargement and rotation, including lanczos, bicubic, hamming, bilinear, box and nearest. Different sampling methods can affect the image quality and processing time of the synthesized image.
  • anti_aliasing: Anti aliasing, ranging from 0 to 16, the larger the value, the less obvious the aliasing. An excessively high value will significantly reduce the processing speed of the node.

image
Generate an image of a specified color and size.

image
Node options:

  • width: Width of the image.
  • height: Height of the image.
  • color4: Color of the image.

The V2 upgraded version of ColorImage.

image
The following changes have been made based on ColorImage:

  • size_as*: Input image or mask here to generate image according to its size. Note that this input takes priority over other size settings.
  • size**: Size preset. the preset can be customized by the user. if have size_as input, this option will be ignored.
  • custom_width: Image width. it valid when size is set to "custom". if have size_as input, this option will be ignored.
  • custom_height: Image height. it valid when size is set to "custom". if have size_as input, this option will be ignored.

*Only limited to input images and masks. forcing the integration of other types of inputs will result in node errors. **The preset size is defined in custom_size.ini, this file is located in the root directory of the plug-in, and the default name is custom_size.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open with text editing software. Each row represents a size, with the first value being width and the second being height, separated by a lowercase "x" in the middle. To avoid errors, please do not enter extra characters.

image
Generate an image with a specified size and color gradient.

image
Node options:

  • width: Width of the image.
  • height: Height of the image.
  • angle: Angle of gradient.
  • start_color4: Color of the begging.
  • end_color4: Color of the ending.

The V2 upgraded version of GradientImage.

image
The following changes have been made based on GradientImage:

  • size_as*: Input image or mask here to generate image according to its size. Note that this input takes priority over other size settings.
  • size**: Size preset. the preset can be customized by the user. if have size_as input, this option will be ignored.
  • custom_width: Image width. it valid when size is set to "custom". if have size_as input, this option will be ignored.
  • custom_height: Image height. it valid when size is set to "custom". if have size_as input, this option will be ignored.

*Only limited to input images and masks. forcing the integration of other types of inputs will result in node errors. **The preset size is defined in custom_size.ini, this file is located in the root directory of the plug-in, and the default name is custom_size.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open with text editing software. Each row represents a size, with the first value being width and the second being height, separated by a lowercase "x" in the middle. To avoid errors, please do not enter extra characters.

image
Rating bulk pictures and outputting top-ranked pictures. it used [ImageReward] (https://github.com/THUDM/ImageReward) for image scoring, thanks to the original authors.

image
Node options:

  • prompt: Optional input. Entering prompt here will be used as a basis to determine how well it matches the picture.
  • output_nun: Number of pictures outputted. This value should be less than the picture batch.

Outputs:

  • images: Bulk pictures output from high to low in order of rating.
  • obsolete_images: Knockout pictures. Also output in order of rating from high to low.

image
Generate simple typesetting images and masks from text. This node references some of the functionalities and code of ZHO-ZHO-ZHO/ComfyUI-Text_Image-Composite, thanks to the original author.

image
Node options:

  • size_as*: The input image or mask here will generate the output image and mask according to their size. this input takes priority over the width and height below.
  • font_file**: Here is a list of available font files in the font folder, and the selected font files will be used to generate images.
  • align: Alignment options. There are three options: center, left, and right.
  • char_per_line: The number of characters per line, any excess will be automatically wrapped.
  • leading: The leading space.
  • font_size: The size of font.
  • text_color: The color of text.
  • stroke_width: The width of stroke.
  • stroke_color: The color of stroke.
  • x_offset: The horizontal offset of the text position.
  • y_offset: The vertical offset of the text position.
  • width: Width of the image. If there is a size_as input, this setting will be ignored.
  • height: Height of the image. If there is a size_as input, this setting will be ignored.

*Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.

**The font folder is defined in resource_dir.ini, this file is located in the root directory of the plug-in, and the default name is resource_dir.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name. all font files in this folder will be collected and displayed in the node list during ComfyUI initialization. If the folder set in ini is invalid, the font folder that comes with the plugin will be enabled.

image
Generate images and masks from text. support for adjusting the spacing between words and lines, horizontal and vertical adjustments, it can set random changes in each character, including size and position.

image
Node options:

  • size_as*: The input image or mask here will generate the output image and mask according to their size. this input takes priority over the width and height below.
  • font_file**: Here is a list of available font files in the font folder, and the selected font files will be used to generate images.
  • spacing: Word spacing.this value is in pixels.
  • leading: Row leading.this value is in pixels.
  • horizontal_border: Side margin. If the text is horizontal, it is the left margin, and if it is vertical, it is the right margin. this value is represents a percentage, for example, 50 indicates that the starting point is located in the center on both sides.
  • vertical_border: Top margin. this value is represents a percentage, for example, 10 indicates that the starting point is located 10% away from the top.
  • scale: The overall size of the text. the initial size of text is automatically calculated based on the screen size and text content, with the longest row or column by default adapting to the image width or height. adjusting the value here will scale the text as a whole. this value is represents a percentage, for example, 60 represents scaling to 60%.
  • variation_range: The range of random changes in characters. when this value is greater than 0, the character will undergo random changes in size and position, and the larger the value, the greater the magnitude of the change.
  • variation_seed: The seed for randomly. fix this value to individual characters changes generated each time will not change.
  • layout: Text layout. there are horizontal and vertical options to choose from.
  • width: Width of the image. If there is a size_as input, this setting will be ignored.
  • height: Height of the image. If there is a size_as input, this setting will be ignored.
  • text_color: The color of text.
  • background_color: The color of background.

*Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.

**The font folder is defined in resource_dir.ini, this file is located in the root directory of the plug-in, and the default name is resource_dir.ini.example. to use this file for the first time, you need to change the file suffix to .ini. Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name. all font files in this folder will be collected and displayed in the node list during ComfyUI initialization. If the folder set in ini is invalid, the font folder that comes with the plugin will be enabled.

image
Erase objects from the image based on the mask. this node is repackage of IOPaint, powered by state-of-the-art AI models, thanks to the original author.
It is have LaMa, LDM, ZITS,MAT, FcF, Manga models and the SPREAD method to erase. Please refer to the original link for the introduction of each model.
Please download the model files from lama models(Baidu Netdisk) or lama models(Google Drive) to ComfyUI/models/lama folder.

Node optons: image

  • lama_model: Choose a model or method.
  • device: After correctly installing Torch and Nvidia CUDA drivers, using cuda will significantly improve running speed.
  • invert_mask: Whether to reverse the mask.
  • grow: Positive values expand outward, while negative values contract inward.
  • blur: Blur the edge.

image
Split the image channel into individual images.

Node options: image

  • mode: Channel mode, include RGBA, YCbCr, LAB adn HSV.

image
Merge each channel image into one image.

Node options: image

  • mode: Channel mode, include RGBA, YCbCr, LAB adn HSV.

image
Remove the alpha channel from the image and convert it to RGB mode. you can choose to fill the background and set the background color.

Node options: image

  • fill_background: Whether to fill the background.
  • background_color4: Color of background.

image
Merge the image and mask into an RGBA mode image containing an alpha channel.

image
Automatically cutout and crop the image according to the mask. it can specify the background color, aspect ratio, and size for output image. this node is designed to generate the image materials for training models.
*Please refer to the model installation methods for SegmentAnythingUltra and RemBgUltra.

Node options: image

  • background_color4: The background color.
  • aspect_ratio: Here are several common frame ratios provided. alternatively, you can choose "original" to keep original ratio or customize the ratio using "custom".
  • proportional_width: Proportional width. if the aspect ratio option is not "custom", this setting will be ignored.
  • proportional_height: Proportional height. if the aspect ratio option is not "custom", this setting will be ignored.
  • scale_by_longest_side: Allow scaling by long edge size.
  • longest_side: When the scale_by_longest_side is set to True, this will be used this value to the long edge of the image. when the original_size have input, this setting will be ignored.
  • detect: Detection method, min_bounding_rect is the minimum bounding rectangle, max_inscribed_rect is the maximum inscribed rectangle.
  • border_reserve: Keep the border. expand the cutting range beyond the detected mask body area.
  • ultra_detail_range: Mask edge ultra fine processing range, 0 is not processed, which can save generation time.
  • matting_method: The method of generate masks. There are two methods available: Segment Anything and RMBG 1.4. RMBG 1.4 runs faster.
  • sam_model: Select the SAM model used by Segment Anything here.
  • grounding_dino_model: Select the Grounding_Dino model used by Segment Anything here.
  • sam_threshold: The threshold for Segment Anything.
  • sam_prompt: The prompt for Segment Anything.

Output: cropped_image: Crop and replace the background image. box_preview: Crop position preview. cropped_mask: Cropped mask.

The V2 upgrad version of ImageAutoCrop, it has made the following changes based on the previous version: image

  • Add optional input for mask. when there is a mask input, use that input directly to skip the built-in mask generation.
  • Add fill_background. When set to False, the background will not be processed and any parts beyond the frame will not be included in the output range.
  • aspect_ratio adds the original option.
  • scale_by: Allow scaling by specified dimensions for longest, shortest, width, or height.
  • scale_by_length: The value here is used as scale_by to specify the length of the edge.

image
Obtain the width and height of the image.

Output:

  • width: The width of image.
  • height: The height of image.
  • original_size: The original size data of the image is used for subsequent node recovery.

Switch output from multiple input images and masks, supporting 9 sets of inputs. All input items are optional. if there is only image or mask in a set of input, the missing item will be output as None. image

Node options:
image

  • output: Switch output. the value is the corresponding input group. when the random-output option is True, this setting will be ignored.
  • random_output: When this is true, the output setting will be ignored and a random set will be output among all valid inputs.

image
Combine multiple paragraphs of text into one.

image
Used to provide assistance for workflow debugging. When running, the properties of any object connected to this node will be printed to the console.

This node allows any type of input.

image
Output a string.

image
Output a integer value.

image
Output a floating-point value with a precision of 5 decimal places.

image
Output a boolean value.

image
Performs mathematical operations on two numeric values and outputs integer and floating point results*. Supported operations include+, -, *, /, **, //, %.

* The input only supports boolean, integer, and floating point numbers, forcing in other data will result in error.

image
Perform a Boolean operation on two numeric values and output the result*. Supported operations include==, !=, and, or, xor, not, min, max.

* The input only supports boolean, integer, and floating point numbers, forcing in other data will result in error. The and operation between the values outputs a larger number, and the or operation outputs a smaller number.

image
Clean up GPU VRAM and system RAM. any type of input can be accessed, and when executed to this node, the VRAM and garbage objects in the RAM will be cleaned up. Usually placed after the node where the inference task is completed, such as the VAE Decode node.

Node Options:

  • purge_cache: Clean up cache。
  • purge_models: Unload all loaded models。

image
Enhanced save image node. You can customize the directory where the picture is saved, add a timestamp to the file name, select the save format, set the image compression rate, set whether to save the workflow, and optionally add invisible watermarks to the picture. (Add information in a way that is invisible to the naked eye, and use the ShowBlindWaterMark node to decode the watermark). Optionally output the json file of the workflow.

Node Options: image

  • iamge: The input image.
  • custom_path*: User-defined directory, enter the directory name in the correct format. If empty, it is saved in the default output directory of ComfyUI.
  • filename_prefix*: The prefix of file name.
  • timestamp: Timestamp the file name, opting for date, time to seconds, and time to milliseconds.
  • format: The format of image save. Currently available in png and jpg. Note that only png format is supported for RGBA mode pictures.
  • quality: Image quality, the value range 10-100, the higher the value, the better the picture quality, the volume of the file also correspondingly increases.
  • meta_data: Whether to save metadata to png file, that is workflow information. Set this to false if you do not want the workflow to be leaked.
  • blind_watermark: The text entered here (does not support multilingualism) will be converted into a QR code and saved as an invisible watermark. Use ShowBlindWaterMark node can decode watermarks. Note that pictures with watermarks are recommended to be saved in png format, and lower-quality jpg format will cause watermark information to be lost.
  • save_workflow_as_json: Whether the output workflow is a json file at the same time (the output json is in the same directory as the picture).
  • preview: Preview switch.

* Enter%date for the current date (YY-mm-dd) and %time for the current time (HH-MM-SS). You can enter / for subdirectories. For example, %date/name_%tiem will output the image to the YY-mm-dd folder, with name_HH-MM-SS as the file name prefix.

image
Add an invisible watermark to a picture. Add the watermark image in a way that is invisible to the naked eye, and use the ShowBlindWaterMark node to decode the watermark.

Node Options: image

  • iamge: The input image.
  • watermark_image: Watermark image. The image entered here will automatically be converted to a square black and white image as a watermark. It is recommended to use a QR code as a watermark.

Decoding the invisible watermark added to the AddBlindWaterMark and SaveImagePlus nodes. image

Generate a square QR code picture.

Node Options:
image

  • size: The side length of image.
  • border: The size of the border around the QR code, the larger the value, the wider the border.
  • text: Enter the text content of the QR code here, and multi-language is not supported.

Decoding the QR code.

Node Options:
image

  • image: The input QR code image.
  • pre_blur: Pre-blurring, you can try to adjust this value for QR codes that are difficult to identify.

image
image
Load the PSD format file and export the layers.

Node Options:
image

  • image: Here is a list of *.psd files under ComfyUI/input, where previously loaded psd images can be selected.
  • file_path: The complete path and file name of the psd file.
  • include_hidden_layer: whether include hidden layers.
  • find_layer_by: The method for finding layers can be selected by layer key number or layer name. Layer groups are treated as one layer.
  • layer_index: The layer key number, where 0 is the bottom layer, is incremented sequentially. If include_hiddenlayer is set to false, hidden layers are not counted. Set to -1 to output the top layer.
  • layer_name: Layer name. Note that capitalization and punctuation must match exactly.

Outputs: flat_image: PSD preview image. layer_iamge: Find the layer output. all_layers: Batch images containing all layers.

image

Reproduction of Photoshop's layer Style - Blend If function. This node outputs a mask for layer composition on the ImageBlend or ImageBlendAdvance nodes. mask is an optional input, and if you enter a mask here, it will act on the output. image

Node Options:
image

  • invert_mask: Whether to reverse the mask.
  • blend_if: Channel selection for Blend If. There are four options: gray , red, green, and blue.
  • black_point: Black point values, ranging from 0-255.
  • black_range: Dark part transition range. The larger the value, the richer the transition level of the dark part mask.
  • white_point: White point values, ranging from 0-255.
  • white_range: Brightness transition range. The larger the value is, the richer the transition level of the bright part mask is.

Detect the area where the mask is located and output its position and size. image

Node options:
image

  • detect: Detection method, min_bounding_rect is the minimum bounding rectangle of block shape, max_inscribed_rect is the maximum inscribed rectangle of block shape, and mask-area is the effective area for masking pixels.
  • x_adjust: Adjust of horizontal deviation after detection.
  • y_adjust: Adjust of vertical offset after detection.
  • scale_adjust: Adjust the scaling offset after detection.

Output:

  • box_preview: Preview image of detection results. Red represents the detected result, and green represents the adjust output result.
  • x_percent: Horizontal position output in percentage.
  • y_percent: Vertical position output in percentage.
  • width: Width.
  • height: Height.
  • x: The x-coordinate of the top left corner position.
  • y: The y-coordinate of the top left corner position.

Improvements to ComfyUI Segment Anything, combined with the Alpha Matte node of ComfyUI-Image-Filters in spacepxl, result in more detailed edges for masks, thanks to the original author.

*Please refer to the installation of ComfyUI Segment Anything to install the model. If ComfyUI Segment Anything has been correctly installed, you can skip this step.

image
image

Node options:
image

  • sam_model: Select the SAM model.
  • ground_dino_model: Select the Grounding DINO model.
  • threshold: The threshold of SAM.
  • detail_range: Edge detail range.
  • black_point: Edge black sampling threshold.
  • white_point: Edge white sampling threshold.
  • process_detail: Set to false here will skip edge processing to save runtime.
  • prompt: Input for SAM's prompt.

The V2 upgraded version of SegmentAnythingUltra has added the VITMatte edge processing method.(Note: Images larger than 2K in size using this method will consume huge memory) image

On the basis of SegmentAnythingUltra, the following changes have been made: image

  • detail_method: Edge processing methods. provides VITMatte, VITMatte(local), PyMatting, GuidedFilter. If the model has been downloaded after the first use of VITMatte, you can use VITMatte (local) afterwards.
  • detail_erode: Mask the erosion range inward from the edge. the larger the value, the larger the range of inward repair.
  • detail_dilate: The edge of the mask expands outward. the larger the value, the wider the range of outward repair.

Remove background. compared to the similar background removal nodes, this node has ultra-high edge details.

This node combines the Alpha Matte node of Spacepxl's ComfyUI-Image-Filters and the functionality of ZHO-ZHO-ZHO's ComfyUI-BRIA_AI-RMBG, thanks to the original author.

*Download the BRIA Background Removal v1.4 model file (model.pth) to the /ComfyUI/models/rmbg/RMBG-1.4 folder. This model was developed by BRIA AI and can be used as an open-source model for non-commercial purposes.
**After downloading the model, recommended to add a line 'rmbg: models/rmbg/RMBG-1.4' in ComfyUI/extra_model_paths.yaml. (This step is not mandatory)

image

Node options:
image

  • detail_range: Edge detail range.
  • black_point: Edge black sampling threshold.
  • white_point: Edge white sampling threshold.
  • process_detail: Set to false here will skip edge processing to save runtime.

The V2 upgraded version of RemBgUltra has added the VITMatte edge processing method.(Note: Images larger than 2K in size using this method will consume huge memory)

On the basis of RemBgUltra, the following changes have been made: image

  • detail_method: Edge processing methods. provides VITMatte, VITMatte(local), PyMatting, GuidedFilter. If the model has been downloaded after the first use of VITMatte, you can use VITMatte (local) afterwards.
  • detail_erode: Mask the erosion range inward from the edge. the larger the value, the larger the range of inward repair.
  • detail_dilate: The edge of the mask expands outward. the larger the value, the wider the range of outward repair.

Using the BiRefNet model to remove background has better recognition ability and ultra-high edge details. The code for the model part of this node comes from Viper's ComfyUI-BiRefNet,thanks to the original author.

*From https://huggingface.co/ViperYX/BiRefNet download the BiRefNet-ep480.pth,pvt_v2_b2.pth,pvt_v2_b5.pth,swin_base_patch4_window12_384_22kto1k.pth, swin_large_patch4_window12_384_22kto1k.pth 5 files to ComfyUI/models/BiRefNet folder.

image

Node options:
image

  • detail_method: Edge processing methods. provides VITMatte, VITMatte(local), PyMatting, GuidedFilter. If the model has been downloaded after the first use of VITMatte, you can use VITMatte (local) afterwards.
  • detail_erode: Mask the erosion range inward from the edge. the larger the value, the larger the range of inward repair.
  • detail_dilate: The edge of the mask expands outward. the larger the value, the wider the range of outward repair.
  • black_point: Edge black sampling threshold.
  • white_point: Edge white sampling threshold.
  • process_detail: Set to false here will skip edge processing to save runtime.

Generate masks for portrait's face, hair, body skin, clothing, or accessories. Compared to the previous A Person Mask Generator node, this node has ultra-high edge details. The model code for this node comes from a-person-mask-generator, edge processing code from ComfyUI-Image-Filters,thanks to the original author.

image

Node options:
image

  • face: Face recognition.
  • hair: Hair recognition.
  • body: Body skin recognition.
  • clothes: Clothing recognition.
  • accessories: Identification of accessories (such as backpacks).
  • background: Background recognition.
  • confidence: Recognition threshold, lower values will output more mask ranges.
  • detail_range: Edge detail range.
  • black_point: Edge black sampling threshold.
  • white_point: Edge white sampling threshold.
  • process_detail: Set to false here will skip edge processing to save runtime.

The V2 upgraded version of PersonMaskUltra has added the VITMatte edge processing method.(Note: Images larger than 2K in size using this method will consume huge memory)

On the basis of PersonMaskUltra, the following changes have been made: image

  • detail_method: Edge processing methods. provides VITMatte, VITMatte(local), PyMatting, GuidedFilter. If the model has been downloaded after the first use of VITMatte, you can use VITMatte (local) afterwards.
  • detail_erode: Mask the erosion range inward from the edge. the larger the value, the larger the range of inward repair.
  • detail_dilate: The edge of the mask expands outward. the larger the value, the wider the range of outward repair.

image
Generate masks for characters' faces, hair, arms, legs, and clothing, mainly used for segmenting clothing. The model segmentation code is fromStartHua,thanks to the original author. Compared to the comfyui_segformer_b2_clothes, this node has ultra-high edge details. (Note: Generating images with edges exceeding 2K in size using the VITMatte method will consume a lot of memory)

*Download all model files from https://huggingface.co/mattmdjaga/segformer_b2_clothes to ComfyUI/models/segformer_b2_clothes folder.

Node Options:
image

  • face: Facial recognition switch.
  • hair: Hair recognition switch.
  • hat: Hat recognition switch.
  • sunglass: Sunglass recognition switch.
  • left_arm: Left arm recognition switch.
  • right_arm: Right arm recognition switch.
  • left_leg: Left leg recognition switch.
  • right_leg: Right leg recognition switch.
  • skirt: Skirt recognition switch.
  • pants: Pants recognition switch.
  • dress: Dress recognition switch.
  • belt: Belt recognition switch.
  • shoe: Shoes recognition switch.
  • bag: Bag recognition switch.
  • scarf: Scarf recognition switch.
  • detail_method: Edge processing methods. provides VITMatte, VITMatte(local), PyMatting, GuidedFilter. If the model has been downloaded after the first use of VITMatte, you can use VITMatte (local) afterwards.
  • detail_erode: Mask the erosion range inward from the edge. the larger the value, the larger the range of inward repair.
  • detail_dilate: The edge of the mask expands outward. the larger the value, the wider the range of outward repair.
  • black_point: Edge black sampling threshold.
  • white_point: Edge white sampling threshold.
  • process_detail: Set to false here will skip edge processing to save runtime.

Use the YoloV8 model to detect faces, hand box areas, or character segmentation. Supports the output of the selected number of channels. Download the model files from GoogleDrive or BaiduNetdisk to ComfyUI/models/yolo folder.

image

Node Options:
image

  • yolo_model: Yolo model selection. the model with seg name can output segmented masks, otherwise they can only output box masks.
  • mask_merge: Select the merged mask. all is to merge all mask outputs. The selected number is how many masks to output, sorted by recognition confidence to merge the output.

Outputs:

  • mask: The output mask.
  • yolo_plot_image: Preview of yolo recognition results.
  • yolo_masks: For all masks identified by yolo, each individual mask is output as a mask.

Generate a mask based on the selected color. image

Node Options:
image

  • image: Input image.
  • mask: This input is optional, if there is a mask, only the colors inside the mask are included in the range.
  • color: Color selector. Click on the color block to select a color, and you can use the straws on the color picker panel to pick up the screen color. Note: When using straws, maximize the browser window.
  • color_in_HEX4: Enter color values. If this item has input, it will be used first, ignoring the color selected by the color .
  • threshold: Mask range threshold, the larger the value, the larger the mask range.
  • fix_gap: Repair the gaps in the mask. If there are obvious gaps in the mask, increase this value appropriately.
  • fix_threshold: The threshold for repairing masks.
  • invert_mask: Whether to reverse the mask.

Shadow & Highlight Mask

Generate masks for the dark and bright parts of the image. image

Node options:
image

  • image: The input image.
  • mask: Optional input. if there is input, only the colors within the mask range will be adjusted.
  • shadow_level_offset: The offset of values in the dark area, where larger values bring more areas closer to the bright into the dark area.
  • shadow_range: The transitional range of the dark area.
  • highlight_level_offset: The offset of values in the highlight area, where larger values bring more areas closer to the dark into the highlight area.
  • highlight_range: The transitional range of the highlight area.

Pixel expansion preprocessing on the masked edge of an image can effectively improve the edges of image composit. image

Node options:
image

  • invert_mask: Whether to reverse the mask.
  • mask_grow: Mask expansion amplitude.

Calculate the differences between two images and output them as mask. image

Node options:
image

  • gain: The gain of difference calculate. higher value will result in a more significant slight difference.
  • fix_gap: Fix the internal gaps of the mask. higher value will repair larger gaps.
  • fix_threshold: The threshold for fix_gap.
  • main_subject_detect: Setting this to True will enable subject detection, ignoring differences outside of the subject.

Process rough masks to ultra fine edges. This node combines the Alpha Matte and the Guided Filter Alpha nodes functions of Spacepxl's ComfyUI-Image-Filters, thanks to the original author. image

Node options:
image

  • method: Provide two methods for edge processing: PyMatting and OpenCV-GuidedFilter. PyMatching has a slower processing speed, but for video, it is recommended to use this method to obtain smoother mask sequences.
  • mask_grow: Mask expansion amplitude. positive values expand outward, while negative values contract inward. For rougher masks, negative values are usually used to shrink their edges for better results.
  • fix_gap: Repair the gaps in the mask. if obvious gaps in the mask, increase this value appropriately.
  • fix_threshold: The threshold of fix_gap.
  • detail_range: Edge detail range.
  • black_point: Edge black sampling threshold.
  • white_point: Edge white sampling threshold.

The V2 upgraded version of MaskEdgeUltraDetail has added the VITMatte edge processing method.(Note: Images larger than 2K in size using this method will consume huge memory)
This method is suitable for handling semi transparent areas. The following figure is an example of the difference in output between three methods. image

On the basis of MaskEdgeUltraDetail, the following changes have been made: image

  • method: Edge processing methods. provides VITMatte, VITMatte(local), PyMatting, GuidedFilter. If the model has been downloaded after the first use of VITMatte, you can use VITMatte (local) afterwards.
  • edge_erode: Mask the erosion range inward from the edge. the larger the value, the larger the range of inward repair.
  • edge_dilate: The edge of the mask expands outward. the larger the value, the wider the range of outward repair.

Grow and shrink edges and blur the mask image

Node options: image

  • invert_mask: Whether to reverse the mask.
  • grow: Positive values expand outward, while negative values contract inward.
  • blur: Blur the edge.

Smooth transition and shrink the mask edges while preserving edge details. image

Node options: image

  • invert_mask: Whether to reverse the mask.
  • shrink_level: Shrink the smoothness level.
  • soft: Smooth amplitude.
  • edge_shrink: Edge shrinkage amplitude.
  • edge_reserve: Preserve the amplitude of edge details, 100 represents complete preservation, and 0 represents no preservation at all.

Comparison of MaskGrow and MaskEdgeShrink image

Create motion blur on the mask. image

Node options:
image

  • invert_mask: Whether to reverse the mask.
  • blur: The size of blur.
  • angle: The angle of blur.

Create a gradient for the mask from one side. please note the difference between this node and the CreateGradientMask node. image

Node options: image

  • invert_mask: Whether to reverse the mask.
  • gradient_side: Generate gradient from which edge. There are four directions: top, bottom, left and right.
  • gradient_scale: Gradient distance. The default value of 100 indicates that one side of the gradient is completely transparent and the other side is completely opaque. The smaller the value, the shorter the distance from transparent to opaque.
  • gradient_offset: Gradient position offset.
  • opacity: The opacity of the gradient.

Create a gradient mask. please note the difference between this node and the MaskGradient node. image
image

Node options:
image

  • size_as*: The input image or mask here will generate the output image and mask according to their size. this input takes priority over the width and height below.
  • width: Width of the image. If there is a size_as input, this setting will be ignored.
  • height: Height of the image. If there is a size_as input, this setting will be ignored.
  • gradient_side: Generate gradient from which edge. There are five directions: top, bottom, left, right and center.
  • gradient_scale: Gradient distance. The default value of 100 indicates that one side of the gradient is completely transparent and the other side is completely opaque. The smaller the value, the shorter the distance from transparent to opaque.
  • gradient_offset: Gradient position offset. When gradient_side is center, the size of the gradient area is adjusted here, positive values are smaller, and negative values are enlarged.
  • opacity: The opacity of the gradient.

*Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.

Generate mask contour strokes. image

Node options:
image

  • invert_mask: Whether to reverse the mask.
  • stroke_grow: Stroke expansion/contraction amplitude, positive values indicate expansion and negative values indicate contraction.
  • stroke_width: Stroke width.
  • blur: Blur of stroke.

Preview the input mask image

Invert the mask image

image

Sharp & Soft

Enhance or smooth out details for image. image

Node options: image

  • enhance: Provide 4 presets, which are very sharp, sharp, soft and very soft. If you choose None, you will not do any processing.

Make the skin look smoother. image

Node options: image

  • smooth: Skin smoothness.
  • threshold: Smooth range. the larger the range with the smaller value.
  • opacity: The opacity of the smoothness.

Watercolor painting effect image

Node option: image

  • line_density: The black line density.
  • opacity: The opacity of watercolor effects.

Soft light effect, the bright highlights on the screen appear blurry. image

Node options: image

  • soft: Size of soft light.
  • threshold: Soft light range. the light appears from the brightest part of the picture. in lower value, the range will be larger, and in higher value, the range will be smaller.
  • opacity: Opacity of the soft light.

Channel misalignment. similar to the effect of Tiktok logo. image

Node options: image

  • distance: Distance of channel separation.
  • angle: Angle of channel separation.
  • mode: Channel shift arrangement order.

HDR Effects

enhances the dynamic range and visual appeal of input images. This node is reorganize and encapsulate of HDR Effects (SuperBeasts.AI), thanks to the original author. image

Node options: image

  • hdr_intensity: Range: 0.0 to 5.0, Controls the overall intensity of the HDR effect, Higher values result in a more pronounced HDR effect.
  • shadow_intensity: Range: 0.0 to 1.0,Adjusts the intensity of shadows in the image,Higher values darken the shadows and increase contrast.
  • highlight_intensity: Range: 0.0 to 1.0,Adjusts the intensity of highlights in the image,Higher values brighten the highlights and increase contrast.
  • gamma_intensity: Range: 0.0 to 1.0,Controls the gamma correction applied to the image,Higher values increase the overall brightness and contrast.
  • contrast: Range: 0.0 to 1.0,Enhances the contrast of the image, Higher values result in more pronounced contrast.
  • enhance_color: Range: 0.0 to 1.0,Enhances the color saturation of the image, Higher values result in more vibrant colors.

Simulate the grain, dark edge, and blurred edge of the film, support input depth map to simulate defocus.
This node is reorganize and encapsulate of digitaljohn/comfyui-propost, thanks to the original author. image

Node options: image

  • image: The input image.
  • depth_map: Input depth map to simulate defocus effect. it is an optional input. if there is no input, will simulates radial blur at the edges of the image.
  • center_x: The horizontal axis of the center point position of the dark edge and radial blur, where 0 represents the leftmost side, 1 represents the rightmost side, and 0.5 represents at the center.
  • center_y: The vertical axis of the center point position of the dark edge and radial blur, where 0 represents the leftmost side, 1 represents the rightmost side, and 0.5 represents at the center.
  • saturation: Color saturation, 1 is the original value.
  • grain_power: Grain intensity. larger value means more pronounced the noise.
  • grain_scale: Grain size.
  • grain_sat: The color saturation of grain. 0 represents mono noise, and the larger the value, the more prominent the color.
  • grain_shadows: Grain intensity of dark part.
  • grain_highs: Grain intensity of light part.
  • blur_strength: The strength of blur. larger value means more blurry it becomes.
  • blur_focus_spread: Focus diffusion range. larger value means larger clear range.
  • focal_depth: Simulate the focal distance of defucus. 0 indicates that focus is farthest, and 1 indicates that is closest. this setting only valid when input the depth_map.

Simulate the light leakage effect of the film. please download the light_leak.pkl(Baidu Netdisk) or [light_leak.pkl(Google Drive)]([light_leak.pkl(Google Drive)(https://drive.google.com/file/d/1DcH2Zkyj7W3OiAeeGpJk1eaZpdJwdCL-/view?usp=sharing)), copy the file to ComfyUI/models/layerstyle folder. image

Node options: image

  • light: 32 types of light spots are provided. random is a random selection.
  • corner: There are four options for the corner where the light appears: top left, top right, bottom left, and bottom right.
  • hue: The hue of the light.
  • saturation: The color saturation of the light.
  • opacity: The opacity of the light.

Pseudo color heat map effect. image

Node options: image

  • color_map: Effect type. there are a total of 22 types of effects, as shown in the above figure.
  • opacity: The opacity of the color map effect.

Make the image motion blur image

Node options:

  • angle: The angle of blur.
  • blur: The size of blur.

Make the image gaussian blur image

Node options:

  • blur: The size of blur.

Annotation for notes

1 The layer_image, layer_mask and the background_image(if have input), These three items must be of the same size.

2 The mask not a mandatory input item. the alpha channel of the image is used by default. If the image input does not include an alpha channel, the entire image's alpha channel will be automatically created. if have masks input simultaneously, the alpha channel will be overwrite by the mask.

3 The Blend Mode include normal, multply, screen, add, subtract, difference, darker, color_burn, color_dodge, linear_burn, linear_dodge, overlay, soft_light, hard_light, vivid_light, pin_light, linear_light, and hard_mix. all of 19 blend modes in total.
image
*Preview of the blend mode

3 The BlendModeV2 include normal, dissolve, darken, multiply, color burn, linear burn, darker color, lighten, screen, color dodge, linear dodge(add), lighter color, dodge, overlay, soft light, hard light, vivid light, linear light, pin light, hard mix, difference, exclusion, subtract, divide, hue, saturation, color, luminosity, grain extract, grain merge all of 30 blend modes in total.
Part of the code for BlendMode V2 is from Virtuoso Nodes for ComfyUI. Thanks to the original authors. image
*Preview of the Blend Mode V2

4 The RGB color described by hexadecimal RGB format, like '#FA3D86'.

5 The layer_image and layer_mask must be of the same size.

Stars

Star History Chart

statement

LayerStyle nodes follows the MIT license, Some of its functional code comes from other open-source projects. Thanks to the original author. If used for commercial purposes, please refer to the original project license to authorization agreement.

About

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published