Nodes/Comfyui_PDuse/PD:Image_and_Text
ComfyUI Node

PD:Image_and_Text

Image_and_Text: build the before/after comparison sheet in one node

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PD:Image_and_Text
  • image1
  • image2
  • merged_image
text1before
text2after
longer_size1024
font_size90
padding_up10
padding_down20
font_fileOswald-Bold.ttf
text_styledark

PD:Image_and_Text (ImageBlendText) takes two images, puts them side by side, and stamps a text caption under each one - then hands you one merged image. It's a presentation node, built for exactly one job: before/after comparisons, "原图 vs 效果图" show-and-tell, A/B result sheets. The author's default labels say it all: text1 is "before", text2 is "after".

How it works

Two images in, one out. If the inputs aren't the same size, the node aspect-scales the second to match the first instead of erroring - a small mercy that keeps mismatched outputs from derailing the sheet. longer_size (128–2048, default 1024) caps the longest edge so your comparison doesn't balloon into a 4K monster. The two halves are joined horizontally and a caption band is appended under each, with padding_up and padding_down controlling the whitespace around the text - and padding_down goes all the way to 1000, so you can extend the canvas downward to give the layout room to breathe.

Text is drawn with a TrueType font from the pack's fonts/ folder (font_file, default Oswald-Bold.ttf), at font_size (10–100, default 90). text_style picks dark or white text.

The inputs that matter

  • image1 / image2 - the pair. Order defines left/right and which label lands under which.
  • text1 / text2 - the captions. Supports Chinese, but only if the chosen font covers it (see below).
  • font_file - pick a font that actually renders your text. The shipped list includes CJK faces like Source Han Sans and Alibaba PuHuiTi for a reason.
  • longer_size - the one dial to set if you want uniform output size across a batch.

Output is merged_image, one IMAGE tensor, straight into Save Image.

Installing

This is a node in the 7BEII/Comfyui_PDuse pack. ComfyUI Manager → search "Comfyui_PDuse" → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt

No model downloads. Dependencies are the pack's light Pillow/numpy/opencv set plus torch from ComfyUI.

Where people get burned

Fonts, again - this pack is a font-dependent bunch. The author's own notes warn that font_size under 20 becomes unreadable and above 90 can overflow the canvas; treat 30–80 as the working range. The bigger trap is Chinese text on a Latin font: it renders as tofu boxes. The shipped CJK fonts exist exactly for this; swap font_file to one of those (HYQiHei, Source Han Sans, Alibaba PuHuiTi) before you blame the node. And don't expect this to composite labels over the image - it's a caption strip underneath, which is the right call for comparisons anyway.

CategoryPDuse/Image

Inputs (10)

NameTypeDefaultDescription
image1IMAGE
image2IMAGE
text1STRINGbefore
text2STRINGafter
longer_sizeINT1024128–2048
font_sizeINT9010–100
padding_upINT100–100
padding_downINT200–1000
font_fileCOMBOOswald-Bold.ttf9 options: Oswald-Bold.ttf, Caveat-VariableFont_wght.ttf, HYQiHei-105JF.otf, Alibaba-PuHuiTi-Heavy.ttf, SOURCEHANSANSCN-MEDIUM.OTF, sign_Caveat-VariableFont_wght.ttf, +3
text_styleCOMBOdark2 options: dark, white

Outputs (1)

NameTypeDescription
merged_imageIMAGE