Nodes/ComfyUI-FeiFei/Before / After Compare
ComfyUI Node

Before / After Compare

Before and after in one frame, so you stop squinting at two windows

By aifeifei798·Created about a month ago·Updated 4 days ago· 3
Before / After Compare
  • before
  • after
  • image
◄modeSide by Side (H)►
◄divider0.50►
◄line_width2►
◄show_labelstrue►
◄label_beforeBefore►
◄label_afterAfter►

You added a film grain pass, or a tone curve, or a chromatic aberration tweak, and now you have to decide whether it's better. So you queue one image, open the output folder, queue the other branch, open that too, and flip between two preview tabs hoping you remember what the first one looked like. That is the whole reason this node exists: before and after in, one frame out, with a divider and corner labels.

Grain A/B is exactly the use case. Grain is the cheapest move there is against the "too clean, too plastic" AI look - and the same body of advice is equally blunt that most inherited grade tweaks don't survive a controlled test: fix the seed, change one thing, look. This node is the "look" half of that sentence. Same logic applies to an upscale pass, a sharpen, or a v2 of your tone curve.

How it works

Both inputs are ComfyUI IMAGE tensors. The node converts each frame to 8-bit RGB, hands them to PIL, and renders a new canvas:

  • Side by Side (H) - canvas is twice as wide; before on the left, a vertical divider line, after on the right.
  • Stack (V) - twice as tall; divider across the seam.
  • Wipe (Left-Right) / Wipe (Top-Bottom) - before fills the frame, after is pasted over one side of the split, so you see the same pixels in both states at the same screen position. This is the mode to use for a grade check; your eye catches a halation difference in a wipe that it will happily miss with a 600px gap between two thumbnails.

before sets the geometry. after is Lanczos-resized onto the before size when they differ, which is the point (an upscaled render still compares cleanly) - but note it resizes to the exact box, so a mismatched aspect ratio gets stretched rather than padded. Keep both sides the same aspect or you are grading a distortion.

Batching is forgiving: one frame on a single side broadcasts across the other side's batch (before index modulo its own count), so you can compare one reference frame against a 4-image batch.

The controls worth touching

mode is the one that matters - pick your layout before anything else. show_labels with label_before / label_after is the next one; the tags are drawn on a translucent black plate so they read on bright frames.

divider (0–1, default 0.5) moves the split, and per its tooltip it is only read in the two Wipe modes - cranking it in Side by Side does nothing. line_width (0–16) sets the divider thickness; the tooltip says 0 hides the line, but the shipped code clamps the width to a minimum of 1 before it draws, so you actually get a hairline rather than nothing. Use 1 if that's what you wanted.

There is one output, image, of type IMAGE, and it is not an output node. Wire it into PreviewImage or SaveImage, or nothing will show up and you will assume the node is broken.

Install

Via ComfyUI Manager: search ComfyUI-FeiFei. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/aifeifei798/ComfyUI-FeiFei.git
# restart ComfyUI; nodes land under the FeiFei category

Requirements are stock ComfyUI stuff - torch, numpy, Pillow - plus openai>=1.40 for the pack's LLM nodes, which does nothing here. This node is pure PIL, so it runs on CPU and costs nothing.

Traps

  • Labels come out tiny. They're drawn with PIL's default font at a size derived from the canvas. On a Pillow old enough to lack the sized default font, the code falls back to the ancient fixed-size bitmap font and your "Before"/"After" tags are about ten pixels tall. A current ComfyUI environment has a recent Pillow; if yours doesn't, that's the cause.
  • "After" looks soft. If after is a 4K upscale and before is 1K, the upscale has been shrunk back down to 1K to fit. Perfect for judging grain, colour and contrast; useless for judging detail. For a sharpness check, crop both to the same region first.
  • The output is a viewing artifact. It round-trips through 8-bit, and it carries the overlays. Save it, look at it, but keep feeding the real images (not the compare frame) into your final save node.
  • Non-image input, or a tensor that isn't [B,H,W,C], raises a clear error instead of a mystery crash downstream - worth knowing if you're piping in something exotic.
CategoryFeiFei

Inputs (8)

NameTypeDefaultDescription
beforeIMAGE—
afterIMAGE—
modeCOMBOSide by Side (H)4 options: Side by Side (H), Stack (V), Wipe (Left-Right), Wipe (Top-Bottom)
dividerFLOAT0.500–1Wipe split position. Only read in the two Wipe modes.
line_widthINT20–16Divider line width in pixels. 0 hides the line.
show_labelsBOOLEANtrue—
label_beforeSTRINGBefore—
label_afterSTRINGAfter—

Outputs (1)

NameTypeDescription
imageIMAGE—