Nodes/ComfyPanel/ImageMask_Transform
ComfyUI Node

ImageMask_Transform

Flip and rotate the image and its mask as one unit

By Ginolazy·Created 6 months ago·Updated 2 days ago· 23
ImageMask_Transform
  • image
  • mask
  • image
  • mask
flip_hfalse
flip_vfalse
rotate0

ImageMask_Transform is the "keep them in sync" transform node: it flips horizontally, flips vertically, and rotates an image and its mask together, so the mask always lines up with the pixels it describes. The individual operations are trivial - every image toolkit has a flip - but doing them to both inputs at once, identically, is exactly the kind of thing that silently bites you when you do it by hand with two separate nodes and get one axis wrong.

The inputs are image and mask (both required) plus three controls: flip_h, flip_v, and rotate (0–3, where each increment is a 90° clockwise turn - 0 is no rotation, 1 is 90°, 2 is 180°, 3 is 270°). The outputs are image and mask, transformed. Under the hood it's plain torch: torch.flip on the appropriate tensor axes for each flip, and torch.rot90 for rotation, applied to the image and mask with their respective axis orderings. No resampling, no interpolation, no quality loss - just axis permutations, which is also why it's essentially instant.

The "one unit" part is the point. Because a mask is usually paired with an image (an inpaint region, a selection, a compositing boundary), transforming the image without transforming the mask - or transforming them in slightly different ways - quietly corrupts the pairing, and the bug shows up later as an inpaint that lands in the wrong spot or a composite with a shifted seam. This node closes that gap by construction: whatever flip_h/flip_v/rotate you set applies to both, identically.

It's marked with lazy inputs like the switch nodes, so ComfyUI only computes the transform on what's actually wired. And a small practical note: rotation is applied after flips (the code flips first, then rot90s), so "flip then rotate" is the order of operations - if you rotate then flip in your head and the result looks transposed, that ordering is why.

Where you'd use it: pre-flipping a reference image for composition, correcting orientation before a pass, augmenting input pairs for a batch, or any time a mask needs to travel with its image through a transform. It's a small, correct utility, and "correct" is the feature.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/Ginolazy/ComfyPanel
# restart ComfyUI

or ComfyUI Manager → "ComfyPanel". No models, no extra dependencies beyond the pack's standard set. If your flipped output looks mirrored and shifted, don't blame the node - the mask was already misaligned with the image before the flip. Transformations can't fix a pairing that was wrong upstream.

CategoryComfyPanel/Image & Mask

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
maskMASK
flip_hBOOLEANfalse
flip_vBOOLEANfalse
rotateINT00–3

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK