ComfyUI Node

Move Left_Or_Right

Pan a background under a foreground you barely have to animate

By Isi-dev·Created 2 years ago·Updated 10 months ago· 33
Move Left_Or_Right
  • foreground_images
  • background_image
  • IMAGE
  • MASK
move_rightfalse
speed1
fg_x_offset0
fg_y_offset0
view_width768

This is the side-scroller of the pack: it makes the world slide left or right behind a foreground subject, so a cutout person or vehicle looks like it's moving across a scene. It's the cousin of Move In_Or_Out, and the same family of cheap-and-effective camera tricks - pure compositing math, no model, no inference.

The mechanism is a sliding crop window. You supply a background image and a view_width (default 768). The node crops a window of view_width pixels out of the background, then steps that window horizontally by speed pixels per frame (default 1, up to 50). With move_right off (the default) the window starts at the far right of the background and pans left, so the world streams leftward - a subject composited in the window reads as moving right. Flip move_right and it pans the other way. The foreground is placed centered in the window and alpha-composited, with fg_x_offset / fg_y_offset to reposition it.

Two numbers tell you almost everything about how to use it. Total travel is background_width − view_width, and the pan stops (clamps) when the window hits the end of the background. So for a full pan you want roughly (background_width − view_width) / speed frames. Nice touch: if you feed exactly one foreground image, the node auto-repeats it that many times so the pan completes anyway - a single static subject still gets a full travel clip. That's a genuinely handy behavior for a lazy one-image setup.

Inputs that matter

  • foreground_images - the subject, ideally an RGBA cutout from a background-removal node. RGB in means a solid rectangle out.
  • background_image - the wider-than-view scene. Wider = more room to pan.
  • move_right - direction. Default false = pan left (subject moves right).
  • speed - pixels per frame, not a percentage. 1 is a slow cruise; 10+ is a hurry.
  • view_width - the output frame width (default 768). Must be ≤ background width to pan at all.
  • fg_x_offset / fg_y_offset - reposition the subject. Same quirk as Move In_Or_Out: positive fg_y_offset is ignored in the current code, negative shifts it up.

Outputs are IMAGE (composited frames) and MASK - again an all-zero placeholder, don't count on it.

Installing it

Part of ComfyUI-Animation_Nodes_and_Workflows by Isi-dev, alongside seven siblings:

  • ComfyUI Manager → search ComfyUI-Animation_Nodes_and_Workflows → install, restart.
  • Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Isi-dev/ComfyUI-Animation_Nodes_and_Workflows
cd ComfyUI-Animation_Nodes_and_Workflows
pip install -r requirements.txt

No model files, no GPU needed - it's OpenCV/numpy on CPU. The pack's mediapipe requirement exists for its LivePortrait node, not this one.

Common gotchas

  • The pack's portrait_walk_left_or_right.json shows the canonical chain: Make Portrait Walk → Move Left_Or_Right → VHS_VideoCombine. The bob of the walk node plus this pan is what makes a person convincingly cross the screen.
  • If the pan stops before the background's end, you ran out of frames - add frames or raise speed so you clear the distance.
  • Same background-removal advice as its siblings: a clean cutout is the difference between a slick effect and a moving rectangle.

Reach for it when you need a character, car, or bike to travel across a scene without animating the travel itself. It's a two-node trick with a genuinely good result.

Categoryimage

Inputs (7)

NameTypeDefaultDescription
foreground_imagesIMAGE
background_imageIMAGE
move_rightBOOLEANfalse
speedINT11–50
fg_x_offsetINT0-16384–16384
fg_y_offsetINT0-16384–16384
view_widthINT768-16384–16384

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK