Nodes/AK Pack/AK Resize On Boolean
ComfyUI Node

AK Resize On Boolean

A resize you can switch off with one checkbox

By akawana·Created 9 months ago·Updated 7 days ago· 2
AK Resize On Boolean
  • image
  • mask
  • image
  • mask
do_resizetrue
width0
height0
resize_algorithmnearest-exact
resize_typestretch
pad_color0, 0, 0
crop_positioncenter

AK Resize On Boolean is a resize node with a switch. It resizes an image (and an optional mask in lockstep) to a target width and height - but only when a boolean is true. Flip the boolean off and the image passes through untouched. That one extra input is the entire point, and it exists for a very specific reason: the author's Project Settings panel.

Project Settings is one of the pack's UI panels that collects all your img2img inputs in one toolbar. It hands out values like target resolution and whether resizing should even happen. This node is the consumer for exactly that: the panel toggles do_resize, this node either resizes the incoming image/mask or leaves them alone, and you never rewire anything when you change your mind. It's a small node, but in a workflow where you flip between "resize to 1024" and "keep native size" constantly, it removes a whole class of tedious editing.

The inputs. Required: do_resize (the boolean switch), width, height, resize_algorithm (nearest-exact, bilinear, bicubic, lanczos), resize_type (stretch, fit, pad, crop), pad_color (a "R, G, B" string), and crop_position (center, top, bottom, left, right). Optional: image and mask.

The resize modes behave the way you'd hope: stretch forces it to exactly width×height, fit scales to fit inside the box, pad fits then fills the rest with pad_color, and crop scales to cover the box then crops, anchored by crop_position. lanczos is your quality pick for real resizing; nearest-exact is the fast, pixel-crisp choice when you're resizing masks and don't want interpolation smearing your edges.

The outputs. image and mask, always both. The mask is transformed with the exact same geometry as the image, so a mask you drew on the original lines up with the resized image - that's the thing that keeps inpainting regions honest after a resize.

How to install. ComfyUI Manager (search "AK Pack") or:

cd ComfyUI/custom_nodes
git clone https://github.com/akawana/ComfyUI-Utils-extra

Restart ComfyUI. No dependencies, no models.

Where people get burned. Width and height of 0 are treated as "no resize" - the image passes through even with do_resize on, so double-check you actually set dimensions if nothing is changing size. The node always emits both outputs, and if you feed neither image nor mask it returns 1×1 empty placeholders rather than erroring; wire a real image and it's fine, but don't be surprised by the tiny tensor if you look at an unconnected output. And while the boolean can come from any source, it shines with the Project Settings panel - if you're not using that panel, you're just driving a checkbox with a wire, which is fine but undercuts why the node exists.

CategoryAK/image

Inputs (9)

NameTypeDefaultDescription
do_resizeBOOLEANtrue
widthINT0
heightINT0
resize_algorithmCOMBOnearest-exact4 options: nearest-exact, bilinear, bicubic, lanczos
resize_typeCOMBOstretch4 options: stretch, fit, pad, crop
pad_colorSTRING0, 0, 0
crop_positionCOMBOcenter5 options: center, top, bottom, left, right
imageoptIMAGE
maskoptMASK

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK