Extensions/comfyui-auto-size
ComfyUI Extension

comfyui-auto-size

ComfyUI plugin providing auto-sized image and latent nodes with model-aligned resolutions.

By jluo-github·Created 6 months ago·Updated 4 months ago· 0
jluo-github/comfyui-auto-size
Nodes2
On cloudLocal install
Categoryimage/AutoSize, latent/AutoSize
Stars0
Updated4 months ago
Readme

ComfyUI Auto Size

Python 3.10+ Code style: ruff License: MIT Tests

A ComfyUI custom node for handling image resolutions with smart, model-aware presets for 2026 diffusion models.

🌟 Supported Models

| Model | Use Case | Resolution Multiple | Source | |-------|----------|---------------------|--------| | Qwen-Image | Text-image-to-image | 28px | Official docs | | Illustrious | Anime | 32px | Community standard | | Z-Image | Text-image-to-image | 32px | Official docs | | Flux2-Klein/Flux | Text-image-to-image | 32px | Similar to Z-Image/Illustrious |

✨ Features

  • Dynamic Dropdowns: Size dropdown filters to show only relevant presets for your selected model
  • Model-Aware Snapping: Automatically rounds resolutions to required multiples (28px or 32px)
  • Robust Resizing: Multiple resize modes—Center Crop, Scale to Fit, Stretch to Fill

📦 Nodes

Auto Size Latent

Category: latent/AutoSize

Generates an empty latent tensor at a model-aligned resolution.

| Input | Description | |-------|-------------| | model | Target model (qwen-image, z-image, flux, illustrious) | | size | Preset or "Full Custom" | | custom_longer_size | Longer side in pixels (set to 0 to use preset) | | custom_ratio | Aspect ratio for custom mode | | batch_size | Number of latents |

Outputs: latent, width, height, size

Auto Size (Image/Mask)

Category: image/AutoSize

Resizes an existing image and/or mask to target dimensions.

| Input | Description | |-------|-------------| | crop_method | Center Crop, Top-Left Crop, Scale to Fit, Stretch to Fill | | scale_method | lanczos, bicubic, bilinear, nearest | | image | Optional input image | | mask | Optional input mask |

Outputs: image, mask, width, height, size

🛠️ Installation

cd ComfyUI/custom_nodes
git clone https://github.com/jluo-github/comfyui-auto-size.git

Restart ComfyUI and reload the browser.

⚙️ Resolution Logic

  1. Custom Override (custom_longer_size > 0): Calculates resolution from longer side + ratio, snapped to model's multiple
  2. Preset Mode (custom_longer_size = 0): Uses the Size dropdown value directly

� Project Structure

nodes/     ComfyUI node definitions
utils/     Core logic (presets, resizing)
js/        Dynamic dropdown behavior
tests/     Unit tests

License

MIT License


Made with ❤️ for the ComfyUI community