Nodes/Edge Painter/Edge Pencil (retouch a guide in black & white)
ComfyUI Node

Edge Pencil (retouch a guide in black & white)

Draw the line your Canny missed, in black and white

By JacPointLab·Created 20 days ago·Updated 20 days ago· 1
Edge Pencil (retouch a guide in black & white)
  • guide
  • size_like
  • guide
  • edited_mask
◄image►
◄source►

You can't hand-draw a guide unless you have something to draw on. Edge Pencil is the other half of Edge Painter, the pack's blank-canvas node, and what it gives you is a pencil for the edge map itself.

The workflow is one line long: take the Canny (or Lineart, HED, depth - anything that outputs an IMAGE) of your photo at the photo's own resolution, feed it to Edge Pencil, run once, and touch the map up by hand - thin lines that should be there and aren't, speckle that shouldn't be there and is. Then run again and the corrected guide goes into your ControlNet.

How it works, because the two-pass thing is odd

ComfyUI can't pause mid-graph and wait for you to draw, so the node does a trick with ComfyUI's input folder.

First run: guide is resized to match size_like (your original photo - preprocessors return their own resolution), hashed with SHA-256, and saved as input/edge_pencil/guide_<hash>.png if that exact map isn't there yet. You get the plain guide back plus an empty mask, and the frontend quietly points the node's two hidden string widgets at the saved file and its fingerprint. It's an output node, so this run happens even with nothing wired downstream - that's what makes "run once" work.

You paint. Right-click → Open in MaskEditor. White adds lines; press X to flip to black and erase them; X again goes back. White and black each keep their own brush size, and black starts fatter (12 px) because erasing wants a fatter brush. Save.

Second run: the node reads the retouched PNG, lays its paint layer over the RGB, resizes back, and diffs it against the freshly computed guide - anything that moved by more than a hair becomes edited_mask. The guide output is now your hand-corrected map, at the photo's size.

The fingerprint saves you from redoing work: while the incoming guide is byte-identical (same photo, same thresholds, same size_like), the node reloads your retouched file and keeps your edits. Change the photo, the thresholds or the reference size and it starts over from the new guide. That's deliberate, and there's a restart from guide button on the node when you want to throw your edits away on purpose.

Inputs and outputs

Required: guide (IMAGE) - plus image and source, which are managed by the node and hidden by the frontend; leave them alone. Optional but effectively mandatory: size_like, the original photo.

Two outputs. guide → your ControlNet Apply node, preprocessor set to none. edited_mask (MASK) marks where you painted, if you want to keep it for something else or eyeball it with a mask preview.

Install

Same pack, same drill. Manager: search Edge Painter. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/JacPointLab/ComfyUI-EdgePainter

Restart ComfyUI. Zero dependencies - no pip install, no model downloads. You do want a 2025-or-later frontend here, for a more concrete reason than on Edge Painter: the X-to-erase toggle and the hidden-widget plumbing both live in the pack's frontend script, so on an older frontend you're left with a node that round-trips a guide and not much else.

Where people get burned

  • You are editing a bitmap, and black is black. The erased line doesn't come back - you painted pure black over those pixels. A soft grey anti-aliased edge you erase is simply gone, and re-running won't restore it. restart from guide is the undo button, and it drops everything.
  • Skip size_like and you inherit the preprocessor's resolution. A 512 px Canny feeding a 1024 px generation gives soft control, because the ControlNet is looking at a smeared-up edge map. Wire the photo in and let the node put the guide back to full size.
  • A new guide wipes your session - new photo, different Canny thresholds, different reference image size. Deterministic Canny on the same input is stable, so repeated runs on an unchanged graph are fine; touch the preprocessor sliders and you're starting from scratch.
  • edited_mask is a difference, not a brush record. It's computed from where the output actually changed, so painting black over a region that was already black marks nothing at all.
  • ComfyUI/input/ grows. One guide_<hash>.png per distinct guide, plus a MaskEditor save per session. Nothing breaks; it's clutter you'll want to sweep occasionally.

Worth saying plainly: this pack has no community footprint yet - no threads, no issue history, no "everyone hits this" reports. The failure modes above come from reading the shipped code, not from a pile of users agreeing on them.

If you only install one node from this pack, make it this one. Re-running a preprocessor with slightly different thresholds until the map stops annoying you is a real time sink, and this replaces it with thirty seconds of drawing.

Categoryimage

Inputs (4)

NameTypeDefaultDescription
guideIMAGEThe guide to retouch, e.g. the output of a Canny preprocessor.
imageSTRINGManaged by the node: the guide file you paint on.
sourceSTRINGManaged by the node: fingerprint of the guide.
size_likeoptIMAGEThe original photo: the guide is resized to its exact size (preprocessors return their own resolution).

Outputs (2)

NameTypeDescription
guideIMAGEThe guide with your white and black retouches, at the size of the original photo.
edited_maskMASKWhere you painted (1 = retouched).