# ComfyUI Image Resizing Precision dimension control nodes for aspect ratio adjustments and resizing workflows. ## Installation Clone into the ComfyUI `custom_nodes` directory and restart ComfyUI: ```bash cd ComfyUI/custom_nodes git clone https://github.com/Zar4X/ComfyUI-Image-Resizing.git image-resizing ``` ## Nodes Overview ### Smart Image Resize Resizes images to fit `min_resolution` / `max_resolution` constraints: shrinks oversized images, iteratively upscales small ones (model-based if `upscale_model` is provided, otherwise interpolation), and tolerates extreme aspect ratios when the area/sum checks pass. `standard_ratio` pads to the nearest standard ratio (3:4, 4:3, 1:1, 16:9, 9:16); `image_reference` pads to match a reference image's ratio instead. Set `upscale_factor` to `1.0` to disable upscaling and only shrink images that exceed `max_resolution`. ### Resize To Multiple Resizes to dimensions divisible by a given number, by stretching or center-cropping. ### Image Crop By Percentage Crops with per-side percentage or pixel values. Percentages are defined over each side's half-axis (`100` reaches the center); negative values expand outward toward the boundary. Also returns the crop origin. ### Mask Crop By Percentage Crops image and mask together around a region detected from the mask: `mask_area`, `min_bounding_rect`, `max_inscribed_rect`, or `crop_each_region` (one crop per connected region). Supports percentage/pixel reserves, rounding to multiples, an optional external `crop_box`, and outputs a `box_preview` overlay. ### Remove Padding Auto-trims black or transparent borders by threshold, or trims to a provided mask's content area. ### Extend Canvas By Percentage Expands the canvas by percentage or pixels with a fill color (`#RRGGBB` or `R,G,B`), optional mask carry-over, edge feathering, and mask inversion. ### Apply Mask To Image Composites a mask onto an image with `output_mode`: `transparent` (RGBA), `black`, or `white` (RGB against that background). ### Resolution / Aspect Ratio Extractors **Image Resolution Extractor** returns width, height, shortest, or longest side in pixels. **Image Aspect Ratio Extractor** returns the ratio after optional per-side crops, either exact (`65:128`) or rounded to common ratios, clamped to 1:4–4:1. ## Behavior Notes - Percentage crop inputs are clamped to `-100..100`; pixel mode accepts signed values. - Crop operations never produce empty regions (boxes are clamped to at least 1 px). ## Requirements - ComfyUI with Pillow, numpy, and opencv-python (see `requirements.txt`) Current package version: `1.1.1`