Nodes/ComfyUI Assistant Node/PVL Crop to Aspect Ratio
ComfyUI Node

PVL Crop to Aspect Ratio

The one node that does exactly one thing, and does it locally

By pvlprk·Created about a year ago·Updated 8 months ago· 1
PVL Crop to Aspect Ratio
  • image
  • image
aspect_ratio16:9

Most of the nodes in the pvlprk/comfyui-pvl-api-nodes pack want an API key and spend money per run. PVL Crop to Aspect Ratio is the odd one out: it's a plain local utility with no network call, no key, and nothing to install beyond the pack itself. It takes an image and crops it to whatever aspect ratio you type, center-crop style, without resizing a single pixel. That's it. In a pack that otherwise drags your GPU-loading work to a cloud API, this one is refreshingly boring - and that's the point.

Why would you reach for it? Because aspect ratios matter more than people admit. Feed a Flux or Qwen node a 4:3 image when the API expects 16:9 and you either get letterboxing, a squeeze, or an API error about image dimensions. Slap this node in front of the call, type 16:9, and the frame gets cropped to exactly that ratio before it ever leaves your machine. It's also handy for prepping a consistent canvas for image-batch workflows where every frame has to match.

How it works

It parses your aspect_ratio string (accepts 16:9, 4x5, 3/2, or a bare float like 1.7778), compares it to the image's current width/height, and crops the longer dimension down to match - centered, so you lose an even slice off both edges rather than one side. If the image already matches the target ratio (within rounding to a pixel grid), it passes through untouched. If the string is unparseable, it also passes through, which is a friendly failure mode. It's batch-safe, and the output is an IMAGE with the same image name as the input, so you can drop it straight into the next node's socket.

Inputs

Just two: image (required) and aspect_ratio (a string, default "16:9"). Nothing else. No width, no offset, no "crop from top" option - if you need more control than a centered crop, reach for a dedicated crop node instead.

Install

Same as every node in this pack:

cd ComfyUI/custom_nodes
git clone https://github.com/pvlprk/comfyui-pvl-api-nodes

Restart ComfyUI. You don't need a FAL_KEY for this one, and the heavy dependencies in the pack's requirements.txt aren't exercised by it either - it only touches torch. (You may still have to let ComfyUI Manager install the pack's full dependency list on first load, though.)

Where people get burned

  • It crops, it never pads. If you need a 16:9 output but can't afford to lose the top and bottom of a photo, this isn't the node - you'd want outpainting or a pad node, not a crop.
  • Ratio strings are parseable but picky. 16:9 works, 16.9 doesn't (that reads as a single float 16.9 - very tall). Check your syntax if the crop comes out weird.
  • The pass-through on "already matches" can surprise you: a 1920x1080 image with 16:9 set comes back pixel-identical, which is correct, but it means you can't use this node to force-resize. That's what it's for - keeping your pixels honest.
CategoryPVL_tools

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
aspect_ratioSTRING16:9

Outputs (1)

NameTypeDescription
imageIMAGE