Nodes/comfyui-dreambait-nodes/Image Resize Face Aware
ComfyUI Node

Image Resize Face Aware

Resize without cutting people's heads off

By drmbt·Created 2 years ago·Updated 7 months ago· 6
Image Resize Face Aware
  • image
  • IMAGE
  • width
  • height
width512
height512
interpolationlanczos
methodkeep proportion
conditionalways
multiple_of0

Image Resize Face Aware is a resizer with a brain: instead of center-cropping when it has to fit an image to a new aspect ratio, it detects faces and crops to them, so you don't get portraits with the top of the head sheared off. It's a fork of the ComfyUI_essentials Image Resize node (which itself descends from WASasquatch's original), extended with face detection and a "crop to subject" mode. If you prep training datasets - especially face-focused ones - this is the node that stops silently wrecking your crops.

What it does

All the standard resize modes are there (stretch, keep proportion, fill / crop, pad) plus the face-aware additions:

  • crop to face - detects the largest face, crops to it, then resizes the crop to your target width/height. Output is always square (both dims lock to min(width, height)), so feed it 512×512 for training crops.
  • crop to face (keep_size) - square crop centered on the face but without resizing; you keep the native resolution. Good when resolution matters more than a fixed size.
  • crop to subject / (largest square) / (square dimensions) - the same idea but for general subjects, using OpenCV's spectral-residual saliency to find where the interesting part of the image actually is, instead of guessing center.

The supporting controls: interpolation (lanczos is the default and the right one), condition (only resize when downscaling, upscaling, or based on pixel area - handy for "don't upscale my 1024px images"), and multiple_of to force dimensions to a multiple (e.g. 8 for latent-friendly sizes).

The face detection bit

Face detection runs on OpenCV's DNN face detector (res10_300x300_ssd), and here's the install-relevant catch: the model files are downloaded automatically on first use from GitHub (the prototxt from opencv/opencv, the weights from opencv_3rdparty). If you run the node before the download completes, or offline, the first run can fail; let it finish once with internet, and after that it's local. If no face is found, it falls back to a center crop - graceful, but it means a genuinely faceless image silently gets the dumb crop. When you're building a training set, that fallback is worth auditing with a quick visual pass.

Why you'd reach for it

The KB's LoRA training essay hammers on dataset quality: crops that cut off faces teach the model bad anatomy. When you're bulk-resizing thousands of images for training, the difference between center-crop and face-crop is the difference between a usable dataset and one that produces decapitated characters. This node automates the right choice. Outside training, it's also the right tool for "I need this portrait at 512² without losing the person" - a resize-and-crop one-liner.

Install

It's in drmbt/comfyui-dreambait-nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/drmbt/comfyui-dreambait-nodes

then restart ComfyUI (or ComfyUI Manager, search "comfyui-dreambait-nodes"). Needs opencv-python, which the pack installs. First-run face detection downloads the model files - do it once with internet, and remember crop to face (keep_size) when you want resolution preserved.

Categorydreambooth/image

Inputs (7)

NameTypeDefaultDescription
imageIMAGEInput image to be resized
widthINT5120–16384Target width. Set to 0 to automatically calculate based on height while preserving aspect ratio
heightINT5120–16384Target height. Set to 0 to automatically calculate based on width while preserving aspect ratio
interpolationCOMBOlanczosMethod used for interpolation. Lanczos generally gives best quality, nearest is fastest
methodCOMBOkeep proportionResize method: stretch (distort), keep proportion (scale), fill/crop (fill area and crop excess), pad (add borders), crop to face/subject (detect and crop+resize), crop to face/subject (keep_size) (square crop without resizing)
conditionCOMBOalwaysWhen to apply the resize operation: always, only when downscaling, only when upscaling, or based on total pixel area
multiple_ofINT00–512Ensure output dimensions are multiples of this value. Set to 0 to disable

Outputs (3)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT