Nodes/YG Custom Nodes/YG Poster Layout Scanner
ComfyUI Node

YG Poster Layout Scanner

Auto-detect where the poster's profile photo and name badge go

By mallikarjunaraokoliparthi·Created 2 months ago·Updated about a month ago· 0
YG Poster Layout Scanner
  • images
  • images
  • json_list
  • output_dir
canvas_width1080
canvas_height1920
name_prefixposter
start_index1
quotes
greetings
watermark_width150
watermark_height150
watermark_opacity0.18
profile_min_area_pct2.0
profile_max_area_pct22.0
save_filestrue
resize_to_canvasfalse
zip_chunk_size250
output_folder

This is the most interesting node in the whole pack, and it solves a very specific problem. When you generate "devotional poster" style images with a model like Nano Banana, the model often draws a blank square where a profile photo should go and a wide strip where a name badge belongs. If you're compositing hundreds of those posters, you need to know where those panels are - in code. YG Poster Layout Scanner looks at each generated image, finds the profile-photo frame and the name badge, picks a clean spot for a watermark, and emits that whole layout as JSON. It never draws a single pixel - the image passes through untouched, and the JSON is your instruction sheet for compositing the text, photo, and watermark later.

How it works

Under the hood it's real image analysis, not AI magic. It shrinks the image, computes local variance to separate flat solid-fill areas from textured/detailed ones, and runs connected-component labeling to find contiguous flat panels. Candidate panels are then classified by aspect ratio and size: a square-ish panel of plausible area becomes the profile frame, a wide-and-short panel becomes the name badge. Shape is estimated from how full each bounding box is (square, rounded_rectangle, circle, ellipse, ornate_frame - the model apparently likes drawing ornate ones).

For the watermark it does a separate pass: it searches for the quietest free rectangle that doesn't overlap either panel, biasing toward image edges, using gradient energy to stay off the quote text. Everything is scaled into the canvas_width × canvas_height coordinate space you set, so the JSON is resolution-independent. The whole scan runs at a small working size (384px max dimension) specifically so it stays cheap across thousands of images.

Outputs and the JSON

  • images - the input batch, passed through untouched.
  • json_list - a JSON array with one object per image: image filename, canvas, the quote (greeting + text, matched by position to your input lists), and profile_photo, name_badge, and watermark blocks, each with x, y, width, height (plus shape and a detected flag). If a panel isn't found, it falls back to sensible defaults and marks detected: false.
  • output_dir - where files were written.

It also saves each image as poster_0001.png with a same-name poster_0001.json side by side in ComfyUI/output/yg_posters/<batch>/ (or your output_folder), and can package them into ZIP chunks via zip_chunk_size (250 per archive by default; 0 disables zipping). resize_to_canvas optionally saves the PNG at the exact canvas size.

The inputs you'll actually set

  • images - wire your poster generator's output.
  • canvas_width / canvas_height - the coordinate space for the JSON (defaults 1080×1920). The tooltip notes you can change these any time; the JSON just re-scales.
  • quotes / greetings - one per image, separated by a line containing ---. These get matched by index into the JSON's quote block.
  • name_prefix / start_index - naming for the saved pairs (poster_0001.png / poster_0001.json, ...).
  • profile_min_area_pct / profile_max_area_pct - the size window a panel must fall in to count as a profile frame (defaults 2–22% of the image). If your model draws frames larger or smaller than that, tune these; it's the most likely adjustment you'll make.
  • watermark_width / watermark_height / watermark_opacity - the watermark slot's desired size and the opacity to record in the JSON.

Installing it

It's part of comfyui_yg_nodes (MIT, "YG Custom Nodes" v1.0.4 by Mallikarjuna Rao Koliparthi). No required extra Python dependencies - it uses scipy if present for faster connected-component labeling, and falls back to a pure-Python two-pass algorithm if not, so it works either way. Install via ComfyUI Manager (search comfyui_yg_nodes) or:

cd ComfyUI/custom_nodes
git clone https://github.com/mallikarjunaraokoliparthi/comfyui_yg_nodes.git

Restart ComfyUI; it's under YG Custom Nodes.

Honest expectations

This is a heuristic scanner, not a vision model. If your posters are clean template-style generations, detection is reliable; if the model draws chaotic backgrounds, expect detected: false fallbacks on a chunk of images - the status line tells you how many used fallbacks, and that's your QA signal. The whole pipeline it was built for (generate → scan → composite in another tool using the JSON) is a genuinely slick batch workflow, and the JSON coordinate space makes it easy to drive an external compositor. Just don't assume it'll read a hand-drawn Photoshop file the way it reads a model's generated panels. For its intended lane, it's the most impressive node in this pack by a wide margin.

CategoryYG Custom Nodes

Inputs (16)

NameTypeDefaultDescription
imagesIMAGE
canvas_widthINT108064–8192Coordinate space for the JSON. Change any time.
canvas_heightINT192064–8192
name_prefixSTRINGposterImage and JSON share this name: poster_0001.png / poster_0001.json
start_indexINT10–999999
quotesoptSTRINGOne quote per image, separated by a line containing ---
greetingsoptSTRINGOne greeting per image, separated by ---. Blank is fine.
watermark_widthoptINT1508–4096
watermark_heightoptINT1508–4096
watermark_opacityoptFLOAT0.180–1
profile_min_area_pctoptFLOAT2.00.1–50
profile_max_area_pctoptFLOAT22.01–90
save_filesoptBOOLEANtrue
resize_to_canvasoptBOOLEANfalseSave the PNG at canvas_width × canvas_height
zip_chunk_sizeoptINT2500–5000Images per ZIP. 0 = do not zip.
output_folderoptSTRINGBlank = ComfyUI output/yg_posters/<batch>

Outputs (3)

NameTypeDescription
imagesIMAGE
json_listSTRING
output_dirSTRING