Nodes/ComfyUI-Apt_Preset/flow_case_tentor
ComfyUI Node

flow_case_tentor

Turn an image's shape into a boolean you can branch on

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
flow_case_tentor
  • data
  • boolean
case_judge
area_threshold1048576.0
ratio_threshold1.0
edge_threshold1024
batch_threshold1

(The name reads like a typo for "case detector," and functionally that's exactly what it is.) This node tests whatever image, mask, or latent you feed it against a condition you pick from a dropdown - landscape vs. portrait, resolution above or below a threshold, aspect ratio above or below a threshold, edge length, or batch count - and hands back a single boolean. Feed that into flow_judge_output or flow_judge_input elsewhere in this pack and you've got a workflow that routes differently depending on the shape of what came in, without you eyeballing every input.

How it works

case_judge has 18 conditions to pick from - things like "landscape image: width > height → True," "square image: width = height → True," "resolution > area threshold → True," "aspect ratio > ratio threshold → True," "long edge > edge threshold → True," and variants covering short edge, height, and batch count against batch_threshold. Whichever one you pick, the node evaluates it against data (any wildcard-typed input - image, mask, or latent all work) and the relevant threshold field, then outputs true or false.

The nice touch is area_threshold and ratio_threshold are typed as STRING, not INT or FLOAT, specifically so you can type an arithmetic expression instead of pre-computing a number - the node's own tooltip gives 1024*1024 and (2000+500)/2 as valid area_threshold values, and 16/9 or 4/3+0.2 for ratio_threshold. That's a genuinely useful bit of ergonomics: you can reason in "1920×1080" terms directly in the field instead of typing 2073600.

Inputs and output

  • case_judge (enum, 18 choices) - which condition to test.
  • area_threshold (STRING, default "1048576.0") - supports arithmetic expressions per its tooltip.
  • ratio_threshold (STRING, default "1.0") - same deal.
  • edge_threshold (INT, default 1024) and batch_threshold (INT, default 1) - the plain-number thresholds for the edge-length and batch-count conditions.
  • data (optional, wildcard) - the image/mask/latent being tested.
  • boolean (output) - the result, ready to wire into a branching node.

Installing it

Search ComfyUI-Apt_Preset in ComfyUI Manager and install, or manually: cd ComfyUI/custom_nodes && git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git, then restart. The README's own dependency step is "double-click install.bat" - Windows-first, no requirements.txt documented, so on Linux/Mac open that file to see what it installs and do the equivalent by hand in your ComfyUI venv. This node is pure logic, so it needs none of the pack's optional extras (GGUF, Advanced-ControlNet, nunchaku, downloaded models).

Common issues

Since case_judge covers 18 different conditions and several of them look similar at a glance (edge vs. short edge vs. height, > vs. = variants), it's easy to pick the wrong one - read the dropdown text carefully rather than assuming from memory which comparison you selected.

Because area_threshold and ratio_threshold are strings that get parsed as expressions, a typo (a stray letter, an unmatched paren) will likely fail at evaluation time rather than at graph-build time - if the node errors only when you actually run the workflow, check those two fields first.

And the pack-wide note: this is one node inside a large, actively developed package, and an import error anywhere in the pack can take it down along with everything else. If it's not showing up after install, check the ComfyUI console at boot for the real traceback.

CategoryApt_Preset/flow

Inputs (6)

NameTypeDefaultDescription
case_judgeCOMBO18 options: 横向图:宽>高,为True, 竖向图:高>宽,为True, 正方图:宽=高,为True, 分辨率>面积阈值,为True, 分辨率=面积阈值,为True, 宽高比>比例阈值,为True, +12
area_thresholdSTRING1048576.0支持加减乘除四则运算表达式,例如:1024*1024、(2000+500)/2
ratio_thresholdSTRING1.0支持加减乘除四则运算表达式,例如:16/9、4/3+0.2
edge_thresholdINT10241–99999
batch_thresholdINT11–9999遮罩或图片或latent,批次数量
dataopt*

Outputs (1)

NameTypeDescription
booleanBOOLEAN