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.
*this workflow (title_example_workflow.json) is in the workflow directory.
Some JSON workflow files in the workflow
directory, That's examples of how these nodes can be used in ComfyUI.
-
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.
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.
This error is caused by incorrect version of the opencv-contrib-python
package,or this package is overwriteen by other opencv packages.
Solution:
- Close ComfyUI and open the terminal window in the plugin directory and execute the following command:
../../../python_embeded/python.exe -s -m pip uninstall -y opencv-python opencv-python-headless opencv-contrib-python-headless opencv-contrib-python
- To avoid other plugins install opencv packages, you can install here first, also can skip this step:
../../../python_embeded/python.exe -s -m pip install opencv-python opencv-python-headless opencv-contrib-python-headless
- Then install
opencv-contrib-python
, ensuring that it is the LAST ONE to be installed:
../../../python_embeded/python.exe -s -m pip install opencv-contrib-python
- Restart ComfyUI.
The solution is the same as above.
This error is caused by the low version of transformers
package. Please upgrade it to the latest version.
Solution:
- Close ComfyUI and open the terminal window in the plugin directory and execute the following command:
../../../python_embeded/python.exe -s -m pip install transformers==4.38.2
- Restart ComfyUI.
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.
When this error has occurred, please check the network environment.
**If the dependency package error after updating, please reinstall the relevant dependency packages. for details, please refer to here.
- 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.
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.
- LayerColor node group provides color adjustment functionality.
- LayerMask nodes provides mask assistance tools.
- LayerUtility nodes provides auxiliary nodes related to layer composit tools and workflows.
- LayerFilter nodes provides image effect filters.
- 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
- 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
- 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
- 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
- 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
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
- 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
LUT Apply
Apply LUT to the image. only supports .cube format.
- 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 plugin. 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.
Auto adjust the color tone of the image to resemble the reference image.
- opacity: The opacity of an image after adjusting its color tone.
Change the exposure of the image.
Color of Shadow & Highlight
Adjust the color of the dark and bright parts of the 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.
Change the gamma value of the image.
- gamma: Value of the Gamma.
Brightness & Contrast
Change the brightness, contrast, and saturation of the image.
- brightness: Value of brightness.
- contrast: Value of contrast.
- saturation: Value of saturation.
Adjust the RGB channels of the image.
- R: R channel.
- G: G channel.
- B: B channel.
Adjust the YUV channels of the image.
- Y: Y channel.
- U: U channel.
- V: V channel.
Adjust the LAB channels of the image.
- L: L channel.
- A: A channel.
- B: B channel.
Adjust the HSV channels of the image.
- H: H channel.
- S: S channel.
- V: V channel.
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.
- 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.
- 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, andmask-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:
- The input
mask_for_crop
reanme tomask
。 - 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.
- 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
Image scaling. when this node is used in pairs, the image can be automatically restored to its original size on the second node.
- 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.
The V2 upgraded version of ImageScaleRestore.
Node options:
The following changes have been made based on ImageScaleRestore:
- scale_by: Allow scaling by specified size on long or short sides.
- scale_by_length: When scale_by is set to "longest", this will be used as the length of the long edge of the image; When set to "shortest", it serves as the length of the short edge.
Scale the image or mask to the size of the reference image (or reference mask).
- 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.
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.
- 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.
V2 Upgraded Version of ImageScaleByAspectRatio
Node options:
The following changes have been made based on ImageScaleByAspectRatio:
- scale_to_side: Allow scaling by specified size on long or short sides.
- scale_to_length: When scale_by_side is set to "longest", this will be used as the length of the long edge of the image; When set to "shortest", it serves as the length of the short edge.
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 plugin. Open it using text editing software, fill in your API key after google_api_key=
and save it.
- aip: 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 plugin. Open it using text editing software, fill in your API key after google_api_key=
and save it.
- image: Optional, input image as a reference for prompt words.
- aip: 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.
- 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.
- 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
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.
Node options:
- mode: The output format is available in hexadecimal (HEX) and decimal (DEC).
Output type:
- value: String format.
Obtain the main color or average color from the image and output RGB values.
- 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.
- 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.
XY to Percent
Convert absolute coordinates to percentage coordinates.
- x: Value of X.
- y: Value of Y.
This node is used to transform layer_image separately, which can change size, rotation, aspect ratio, and mirror flip without changing the image size.
- 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.
- 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.
Generate an image of a specified color and size.
- width: Width of the image.
- height: Height of the image.
- color4: Color of the image.
The V2 upgraded version of ColorImage.
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
, which is located in the root directory of the plugin. 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.
Generate an image with a specified size and color gradient.
- 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.
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
, which is located in the root directory of the plugin. 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.
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.
- 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 plugin.
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.
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.
- 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 plugin.
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.
Erase objects from the image based on the mask. this node is repackage of IOPaint, powered by state-of-the-art AI models.
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.
- 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.
Split the image channel into individual images.
- mode: Channel mode, include RGBA, YCbCr, LAB adn HSV.
Merge each channel image into one image.
- mode: Channel mode, include RGBA, YCbCr, LAB adn HSV.
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.
- fill_background: Whether to fill the background.
- background_color4: Color of background.
Merge the image and mask into an RGBA mode image containing an alpha channel.
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.
- 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.
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.
Combine multiple paragraphs of text into one.
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.
Detect the area where the mask is located and output its position and size.
- 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, andmask-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.
*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.
- From here download the config.json,model.safetensors,tokenizer_config.json,tokenizer.json and vocab.txt 5 files to
ComfyUI/models/bert-base-uncased
folder. - Download GroundingDINO_SwinT_OGC config file, GroundingDINO_SwinT_OGC model,
GroundingDINO_SwinB config file, GroundingDINO_SwinB model to
ComfyUI/models/grounding-dino
folder. - Download sam_vit_h,sam_vit_l,
sam_vit_b, sam_hq_vit_h,
sam_hq_vit_l, sam_hq_vit_b,
mobile_sam to
ComfyUI/models/sams
folder.
- 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)
On the basis of SegmentAnythingUltra, the following changes have been made:
- detail_method: Edge processing methods. provides three methods: VITMatte, PyMatting and GuidedFilter.
- 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.
*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)
- 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:
- detail_method: Edge processing methods. provides three methods: VITMatte, PyMatting and GuidedFilter.
- 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.
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.
- 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:
- detail_method: Edge processing methods. provides three methods: VITMatte, PyMatting and GuidedFilter.
- 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.
Shadow & Highlight Mask
Generate masks for the dark and bright parts of the 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.
- invert_mask: Whether to reverse the mask.
- mask_grow: Mask expansion amplitude.
Calculate the differences between two images and output them as mask.
- 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.
- 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.
On the basis of MaskEdgeUltraDetail, the following changes have been made:
- method: Edge processing methods. provides three methods: VITMatte, PyMatting and GuidedFilter.
- 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
- 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.
- 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
Create motion blur on the mask.
- 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.
- 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.
- 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 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.
*Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.
Generate mask contour strokes.
- 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.
Sharp & Soft
Enhance or smooth out details for image.
- enhance: Provide 4 presets, which are very sharp, sharp, soft and very soft.
- smooth: Skin smoothness.
- threshold: Smooth range. the larger the range with the smaller value.
- opacity: The opacity of the smoothness.
- line_density: The black line density.
- opacity: The opacity of watercolor effects.
Soft light effect, the bright highlights on the screen appear blurry.
- 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.
- distance: Distance of channel separation.
- angle: Angle of channel separation.
- mode: Channel shift arrangement order.
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.
- 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.
- 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.
- 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.
Node options:
- angle: The angle of blur.
- blur: The size of blur.
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.
*Preview of the blend mode
4 The RGB color described by hexadecimal RGB format, like '#FA3D86'.
5 The layer_image and layer_mask must be of the same size.
LayerStyle nodes follows the MIT license, Some of its functional code comes from other open-source projects. If used for commercial purposes, please refer to the original project license to authorization agreement.