AIIA Image Smart Crop
Smart Crop Before the Talking-Head Nodes, So Faces Actually Fit
- image
- IMAGE
If your talking-head video comes out with the mouth weirdly huge or the face drifting out of frame, the problem is usually upstream of the generation - your input image was framed wrong. AIIA Image Smart Crop is a flexible crop/resize node that the README specifically positions before Ditto or other video samplers, to get faces centered and sized right before the model ever sees them. It's a utility, but it's the kind that quietly decides whether your avatar looks right.
How it works
Nothing AI about it - it's clean crop math on an IMAGE tensor. You give it a target and it computes a crop window from an anchor position, then resizes. The cleverness is the crop_basis system, which controls which edge is the anchor:
custom_size- force the exactwidth×heightyou specify.fixed_width/fixed_height- lock one edge at yourwidth/height, let the other adapt to the aspect ratio.fixed_long_side- crop so the long side matches the original long side (ignores width/height). Keeps as much resolution as possible.fixed_short_side- crop to the short side of the source. This is the "maximum crop" mode, useful when you want to punch way in on the face.
aspect_ratio then sets the shape - original, presets like 1:1, 4:3, 16:9, 9:16, 21:9, or custom with your own custom_aspect_ratio number. If the source image is portrait but your video is 16:9, this node handles the reframe in one go.
The inputs that matter
position- a 9-grid anchor:center,top,bottom,left,right, and the four corners. For a talking-head reference,centeron a face-cropped photo is usually right.offset_x/offset_y- relative fine-tuning of the anchor, from -1.0 to 1.0. If the crop keeps cutting off the top of the head, nudgeoffset_ynegative to shift the window up.width/height- only meaningful withcustom_size(or as the fixed edge forfixed_width/fixed_height). Values are stepped to multiples of 8, which keeps the result friendly for latent-space work.
Output is the single cropped/resized IMAGE - straight into AIIA Ditto Sampler's ref_image, or anywhere else you need a specific aspect ratio.
When you actually need it
The sweet spot is pre-processing for video samplers: a square, centered face with minimal background makes Ditto's crop_scale behave, since the model's face-context window then contains mostly face. It's also handy for normalizing mixed-source images to a uniform resolution before batching, or punching a 9:16 vertical crop out of a landscape still for social clips. It won't detect the face for you - that's position and offset, manually - but for a node with zero dependencies and zero model downloads, it's a lot of control.
Install
Standard pack install: havvk/ComfyUI_AIIA via ComfyUI Manager or git clone https://github.com/havvk/ComfyUI_AIIA.git into custom_nodes/, restart. No models, no extra deps - it's pure Pillow math under the hood, so it just works.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 5120–8192 | — |
| height | INT | 5120–8192 | — |
| crop_basis | COMBO | 5 options: custom_size, fixed_width, fixed_height, fixed_long_side, fixed_short_side | |
| aspect_ratio | COMBO | original | 9 options: original, custom, 1:1, 4:3, 3:4, 16:9, +3 |
| custom_aspect_ratio | FLOAT | 1.000.1–10 | — |
| position | COMBO | 9 options: center, top, bottom, left, right, top_left, +3 | |
| offset_x | FLOAT | 0.00-1–1 | — |
| offset_y | FLOAT | 0.00-1–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |