Nodes/ComfyUI_Fill-Nodes/FL Image Aspect Cropper
ComfyUI Node

FL Image Aspect Cropper

Force an image to a specific ratio without distorting it

By filliptm·Created 3 years ago·Updated about 20 hours ago· 628
FL Image Aspect Cropper
  • images
  • IMAGE
aspect_ratio_w16
aspect_ratio_h9

There are two ways to fix an image that's the wrong aspect ratio: squash/stretch it to fit, or crop it. Squashing distorts everything in the frame; cropping keeps every remaining pixel geometrically correct at the cost of losing some content at the edges. FL_ImageAspectCropper does the crop version - you tell it the ratio you want as width:height, and it center-crops whichever dimension is oversized until the image matches that ratio exactly.

How it works

It compares your image's current aspect ratio to the target aspect_ratio_w : aspect_ratio_h. Whichever dimension is "too big" for the target ratio gets trimmed symmetrically from both sides (a center crop), so the subject roughly in the middle of the frame stays roughly in the middle of the result. It also rounds the final dimensions to even numbers - a small but deliberate detail, since odd pixel dimensions break some video codecs downstream (ffmpeg's yuv420p, for one, requires even width and height).

The inputs and outputs that matter

All three are required - there's no optional tuning here, which is part of the appeal:

  • images - what you're cropping.
  • aspect_ratio_w (1–100, default 16) and aspect_ratio_h (1–100, default 9) - the target ratio, expressed as two integers (16:9, 4:3, 1:1, 9:16 for vertical, whatever you need).

Output: a single IMAGE, cropped to that ratio with even dimensions.

How to install it

Ships inside ComfyUI_Fill-Nodes. ComfyUI Manager: search ComfyUI_Fill-Nodes, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes

then restart. Plain tensor cropping - no models, no extra dependencies.

Common issues & troubleshooting

It's a center crop, so off-center subjects get clipped. If your subject isn't roughly centered in the source image, a symmetric crop can cut into it rather than around it. This node has no offset control - if you need to preserve a specific off-center region, crop or reframe before this node rather than relying on it to know what matters in the frame.

You lose content, you don't gain canvas. Because this only crops (never pads or upscales), the output is always smaller than or equal to the input in whichever dimension gets trimmed. If you actually need to add canvas to hit a ratio without losing anything, that's a padding node's job, not this one's.

Feeding it a ratio that's already correct is a safe no-op-ish path, but worth checking your math - aspect_ratio_w/aspect_ratio_h as 16:9 versus accidentally typing 9:16 will crop a landscape image down to a tall sliver instead of leaving it alone, since the node has no idea which orientation you "meant."

Good pairing for video work. The even-dimensions guarantee is specifically there for codec compatibility - if you're feeding results into one of the pack's video-export nodes (or any ffmpeg-based pipeline), running your frames through this first is cheap insurance against an export that fails on an odd pixel count.

Category🏵️Fill Nodes/Image

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
aspect_ratio_wINT161–100
aspect_ratio_hINT91–100

Outputs (1)

NameTypeDescription
IMAGEIMAGE