Files
ausboss-ComfyUI-AusBoss/js/shared/image_size.mjs
ausboss 05038baaa3 Five basics the normal nodes have: sums, any wire into Show Text, name tokens, word weights, Image Size's numbers
Found in a sweep of the pack against ComfyUI's own nodes: things the normal
node does that the pack's node did not.

- Every number box takes a sum. Click a number, type 1024*1.5 or
  (1920-64)/2 and press Enter, as in ComfyUI's own number boxes: + - * / %,
  brackets and a sign. The reader is the pack's own (sumValue in
  js/shared/scrub_input.mjs) and is only asked when the text is not a plain
  number.
- Show Text takes any wire. Its input was STRING only. A number, an on/off
  value or a list is shown too; a picture or a latent is shown by its size.
  The output stays STRING and carries the text that is shown, so text
  passes through unchanged and a number comes out as text.
- Save Image takes name tokens in the file name, as ComfyUI's own Save
  Image does: %date:yyyy-MM-dd% and %Node.setting% are filled in the
  browser when a run is sent (js/shared/name_tokens.mjs, now shared with
  Save Video), %width% %height% and the time tokens on the server. The
  path preview shows them. A linked filename is never read for tokens.
- Ctrl + Up and Ctrl + Down change a word's weight in the pack's prompt
  boxes (Text, Krea 2 Encode). The card's text box stopped the key before
  ComfyUI's own listener saw it; those two keys now go on from a multiline
  box, and from nowhere else.
- Image Size shows what it measured beside its outputs after a run
  ("width: 1024"). The numbers go into the output labels, so the node keeps
  its size. ComfyUI says nothing about a node whose answer came from its
  cache, so the numbers are kept in the node's properties and come back
  when a workflow is opened again; a changed picture wire clears them.

No input was added, renamed or reordered. Help pages, README lines, tests
and CHANGELOG entries are included.
2026-10-11 17:10:52 -05:00

25 lines
1.0 KiB
JavaScript

// Image Size 🆎: what the node shows beside its outputs after a run. No DOM
// and no ComfyUI imports, so node:test covers it.
// The executed message carries [width, height, longest, shortest, count] for
// the batch that was measured. A node that ran once for each item of a list
// reports several batches at once; no one number is true for all of them, so
// that case shows nothing.
export function sizesFromExecuted(message, outputs = 5) {
const sizes = message?.ausboss_size;
if (!Array.isArray(sizes) || sizes.length !== outputs) return null;
return sizes.every((value) => Number.isFinite(value)) ? sizes : null;
}
// "width: 1024": the output's own name, then its number.
export function sizeLabel(name, value) {
return `${name}: ${value}`;
}
// The label an output is saved with: the one its user gave it, never a
// number from the last run. `shown` is false for an output that never showed
// a size, whose saved label is left as it is.
export function savedLabel({ shown, own }, current) {
return shown ? own : current;
}