Nodes/ComfyUI-Apt_Preset/Image_pad_keep
ComfyUI Node

Image_pad_keep

Rotate, scale, and place one image onto another

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_pad_keep
  • image
  • canvas_image
  • image
  • pad_mask
x0
y0
zoom1.00
angle0
shear0
border_handlingedge
scale_modebilinear
constant_colorblack

Not a "pad to fit a model" node like its pad_adjust siblings - this one is a manual transform-and-place tool. Give it an image, dial in position, zoom, rotation, and shear, and it drops the transformed result onto a canvas, optionally an existing image you supply rather than a flat backdrop.

How it works

x/y set position offset, zoom (default 1) scales, angle (−360 to 360) rotates, and shear skews. border_handling (edge/constant/reflect/symmetric) decides what fills in at the transformed image's own edges once it's rotated or sheared off its original rectangle - standard affine-transform boundary handling. scale_mode (nearest-exact/bilinear/area/bicubic/lanczos) picks the interpolation used for the resize. constant_color supplies the fill when border_handling is "constant". canvas_image (optional) lets you place the transformed result onto an existing image instead of a blank one.

The inputs and outputs that matter

  • x/y - position offset of the transformed image, not the destination canvas.
  • zoom (default 1), angle (default 0), shear (default 0) - the actual transform.
  • scale_mode (default "bilinear") - interpolation quality; matters most on rotation and scale.
  • canvas_image (optional) - place onto this instead of a flat background.
  • Output: image, pad_mask.

How to install it

Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

Windows: install.bat. Linux/Mac: pip install -r ComfyUI-Apt_Preset/requirements.txt in your venv. Restart. Nothing to download for this node - the pack's heavier dependencies belong to other parts of this ~300-star, actively maintained pack.

Common issues & troubleshooting

Rotated or sheared edges look jagged. Try a smoother scale_mode - bicubic or lanczos over nearest-exact, which is fast but visibly blocky on anything but plain axis-aligned scaling.

Placement onto canvas_image looks offset from what you expected. x/y position the transformed image, not the destination canvas as a whole. Get zoom and angle right first, then nudge x/y - trying to solve all four at once tends to produce confusing results.

Border artifacts after a big rotation or shear. border_handling decides what fills the gaps a rotated rectangle leaves behind - "edge" (the default) repeats the nearest pixel, "reflect"/"symmetric" mirror the image back on itself, and "constant" uses a flat constant_color fill. If you're seeing streaky repeated pixels at a corner, that's "edge" doing exactly what it's supposed to on a shape that no longer fits its own rectangle - switch to "constant" with a color that matches your scene if a hard edge looks better than a stretched one.

Use case worth knowing about. This is the node for manually placing a generated element into a scene at an angle - a prop, a sticker, a second subject - rather than relying on a model to compose it correctly, or for building a collage where pieces need independent rotation and scale instead of a straight side-by-side layout. Because it also outputs pad_mask, you can feed the result straight into an inpaint pass to blend the placed element into its new background rather than leaving it as an obvious paste.

CategoryApt_Preset/image

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
xFLOAT0-4096–4096
yFLOAT0-4096–4096
zoomFLOAT1.00
angleFLOAT0-360–360
shearFLOAT0-4096–4096
border_handlingCOMBOedge4 options: edge, constant, reflect, symmetric
scale_modeoptCOMBObilinear5 options: nearest-exact, bilinear, area, bicubic, lanczos
constant_coloroptCOMBOblack6 options: white, black, red, green, blue, gray
canvas_imageoptIMAGE

Outputs (2)

NameTypeDescription
imageIMAGE
pad_maskMASK