LayerStyle

2167
By chflame
Updated 15 days ago
View on GitHub →See Common Issues →

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

Available Nodes

LayerMask: MaskStroke

LayerMask: MaskStroke Node Documentation

Overview

The LayerMask: MaskStroke node is a component of the ComfyUI library, provided by the https://github.com/chflame163/ComfyUI_LayerStyle repository. It is designed to manipulate image masks by applying a series of transformations such as inverting, growing, and blurring strokes around specified areas. This can be particularly useful for graphic design or image editing tasks where precise mask manipulation is required.

Functionality

The primary function of the LayerMask: MaskStroke node is to process image masks through its mask_stroke method. This includes:

  • Inverting the mask if required.
  • Adjusting the size of the stroke around the mask.
  • Applying a blur effect to the stroke.

These operations result in modified masks that can control which areas of an image are affected by subsequent image processing nodes.

Inputs

The LayerMask: MaskStroke node requires several inputs to function. These are:

  1. mask: The primary input which is an image mask. The node can handle masks in both single and batch formats.

  2. invert_mask: A boolean flag (either true or false) that determines if the input mask should be inverted before further processing. By default, this is set to true.

  3. stroke_grow: An integer that specifies how much the stroke should shrink or grow. This can range from -999 to 999, allowing for flexible adjustment.

  4. stroke_width: An integer representing the width of the stroke to be applied around or within the mask. It ranges from 0 to 999 and defaults to 20.

  5. blur: An integer determining the amount of blur to apply to the stroke. The blur value can vary from 0 to 100, with a default setting of 6.

Outputs

The LayerMask: MaskStroke node produces a single output:

  • mask: The transformed mask after applying all specified operations. This mask can be used in further image processing applications within a ComfyUI workflow, and it retains the MASK type.

Usage in ComfyUI Workflows

The LayerMask: MaskStroke node is particularly useful in workflows that require intricate mask manipulation. Common use cases include:

  • Preparing masks for advanced compositing tasks where specific areas of an image need to be highlighted or protected.
  • Creating stylized effects around image elements by generating consistent and controlled strokes.
  • Enhancing visual designs by adding detailed contours and borders.

By integrating this node into your workflow, you can achieve detailed control over image masks that can enhance the final output's visual appeal and accuracy.

Special Features and Considerations

  • Mask Inversion: The option to invert masks gives flexibility, allowing for quick toggling between highlighting or excluding designated areas without manually altering the mask data.

  • Flexible Stroke Control: With adjustable growth and width parameters, this node allows for intricate stroke designs, providing both shrinkage and expansion capabilities.

  • Blur Integration: The ability to blur strokes can lead to smoother transitions and more natural-looking effects in composited images.

  • Batch Processing: The node is capable of processing multiple masks at once, making it suitable for batch operations in large-scale image editing projects.

When using the LayerMask: MaskStroke node, consider these features to optimize your image processing workflows effectively.