Nodes/ComfyUI-Apt_Preset/Image_Resize_sum_data
ComfyUI Node

Image_Resize_sum_data

Unpack the resize math from Image_Resize_sum

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_Resize_sum_data
  • stitch
  • image
  • width
  • height
  • x_offset
  • y_offset
  • pad_left
  • pad_right
  • pad_top
  • pad_bottom
  • full_width
  • full_height
  • scale_factor

Image_Resize_sum bundles everything it did - the padding, the offsets, the scale - into one opaque stitch packet so it can undo itself later via Image_Resize_sum_restore. This node is the other way to use that packet: instead of restoring the image, it cracks the bundle open and hands you every number inside as separate INT/FLOAT outputs you can wire wherever you actually need them - into math nodes, into a crop node, into a debug display, wherever plain numbers are more useful than a black-box restore.

How it works

Point it at a stitch bundle and it reads off the padding and offset values Image_Resize_sum recorded. There's a second trick built in: if you also feed it the current image (the optional image input), it recalculates a scale factor on the fly - specifically, current image width divided by the original full width (padding included) - and multiplies every output value by that factor before rounding. That matters if something downstream changed the image's resolution between the original resize and now (an upscaler, say) and you need the offsets/dimensions to scale proportionally with it. Skip the optional image and the scale factor defaults to 1.0, meaning you get the raw numbers back untouched.

The inputs and outputs that matter

  • stitch (STITCH3, required) - the bundle from Image_Resize_sum. This is a pack-specific type; it won't accept a STITCH2 bundle from the Image_solo_crop/Image_solo_crop2 family.
  • image (IMAGE, optional) - feed this to trigger the auto-rescale described above.

Eleven outputs, all INT except the last:

  • width / height - the working (resized) dimensions.
  • x_offset / y_offset - where the working region sits inside the padded canvas.
  • pad_left / pad_right / pad_top / pad_bottom - the padding amounts on each side, if Image_Resize_sum was run in pad or pad_edge mode.
  • full_width / full_height - the total canvas size including padding.
  • scale_factor (FLOAT) - 1.0 unless you fed the optional image, in which case it's the ratio described above.

How to install it

ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manual clone:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
pip install -r requirements.txt

install.bat only runs on Windows; on Linux use pip install -r requirements.txt directly. This node does no image processing of its own beyond arithmetic, so there's nothing to download for it specifically.

Common issues

The whole node is useless without a live stitch connection from an actual Image_Resize_sum run in the same graph - it's not a standalone calculator, it's a decoder for that specific bundle's contents. If your outputs look like they're all zero or default, double check the wire is coming from Image_Resize_sum's stitch output and not, say, Image_Resize_sum_restore's image outputs by mistake.

The auto-rescale behavior is also easy to get backwards: it only activates when you plug something into the optional image input, and it compares that image's width against the original full width including padding - not against the resized region's width. If you're chaining an upscaler afterward and want proportional offsets, feed the upscaled image in here; if you just want the raw numbers Image_Resize_sum recorded, leave image disconnected.

As with the rest of the pack, a from-scratch install pulls a large requirements.txt covering the whole 100+-node suite (onnxruntime, gguf, transparent-background, and more) - none of which this particular node needs, but all of which have to import cleanly for the pack to load at all. If ComfyUI reports IMPORT FAILED for the whole pack, check the console for the specific missing package rather than assuming this node caused it.

CategoryApt_Preset/image/ImgResize

Inputs (2)

NameTypeDefaultDescription
stitchSTITCH3
imageoptIMAGE

Outputs (11)

NameTypeDescription
widthINT
heightINT
x_offsetINT
y_offsetINT
pad_leftINT
pad_rightINT
pad_topINT
pad_bottomINT
full_widthINT
full_heightINT
scale_factorFLOAT