Nodes/ComfyUI Layer Style/LayerStyle: Stroke
ComfyUI Node Runs on cloud

LayerStyle: Stroke

Stroke — a Photoshop outline around your subject, in one node

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerStyle: Stroke
  • background_image
  • layer_image
  • layer_mask
  • image
â—„invert_masktrueâ–º
◄blend_mode▾►
â—„opacity100â–º
â—„stroke_grow0â–º
â—„stroke_width8â–º
â—„blur0â–º
â—„stroke_color#FF0000â–º

You know the sticker look - a subject with a clean colored border traced around its silhouette. In Photoshop that's the Stroke layer style. This node is that, ported straight into ComfyUI. Give it a background, a foreground layer, and a mask of the subject, and it draws an outline that follows the subject's shape and composites the whole thing down.

It's the go-to when you want an image to read as a cutout on purpose: product stickers, comic-panel outlines, meme-style subject emphasis, a caption card where the figure needs to pop off the background. The border traces the mask, not a bounding box, so it hugs the actual silhouette.

How it works

The mask defines the shape. The node grows (or shrinks) that shape to place the stroke, fills the ring with your color, optionally softens it, and blends the result onto the background at the layer's position. Because it's built on the same compositing core as the pack's ImageBlend nodes, it also gives you a blend mode and opacity for the whole layer - so the outlined subject can be laid down normally or in multiply/screen/etc.

The inputs and outputs that matter

  • stroke_color (default #FF0000), stroke_width - the obvious two. Color is a hex string; width is in pixels.
  • stroke_grow - pushes the stroke outward (positive) or inward (negative) relative to the edge. Use it to sit the outline just off the subject or bite into it.
  • blur - softens the stroke from a hard line into a glow-ish edge. Leave at 0 for a crisp sticker border.
  • invert_mask (default true) - the gotcha. If your stroke wraps the background instead of the subject, flip this. LayerStyle's mask convention trips everyone at least once.
  • background_image, layer_image, optional layer_mask - the two images plus the shape. blend_mode (19 options) and opacity control how the finished layer drops onto the background.

Output is a single composited image.

How to install it

Part of the LayerStyle pack. ComfyUI Manager → search LayerStyle → install → restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt

then restart. It shows up under 😺dzNodes → LayerStyle. This particular node is lightweight - no model downloads - but it rides along with the whole pack's dependency list, so let the pip install finish.

Common issues & troubleshooting

The outline is on the wrong side. Ninety percent of the time it's invert_mask. This pack treats mask polarity opposite to what you'd guess, and the default true here is right for some upstream masks and backwards for others. Toggle it and re-run.

No visible stroke. Check stroke_width isn't 0 and opacity isn't dragged down. If the color matches the subject, you won't see it either - that #FF0000 default is deliberately loud so you can confirm placement first, then change it.

The pack didn't load, so the node is missing. If LayerStyle shows "import failed" in Manager, it's usually a broken transformers dependency (commonly a stray TensorFlow) taking the whole pack down on import - the most-reported LayerStyle failure. The Stroke node itself doesn't need transformers, but it can't appear if its pack won't import. Read the traceback, hit "Try Fix," or repair the offending library.

Stroke looks blocky on a small subject. Nudge blur up a touch, or grow the mask slightly upstream before it reaches this node so the silhouette has cleaner curves to trace.

Category😺dzNodes/LayerStyle

Inputs (10)

NameTypeDefaultDescription
background_imageIMAGE—
layer_imageIMAGE—
invert_maskBOOLEANtrue—
blend_modeCOMBO19 options: normal, multply, screen, add, subtract, difference, +13
opacityINT1000–100—
stroke_growINT0-999–999—
stroke_widthINT80–999—
blurINT00–100—
stroke_colorSTRING#FF0000—
layer_maskoptMASK—

Outputs (1)

NameTypeDescription
imageIMAGE—