From 81364107cb7a854f16a57c16e213925b9ba85c85 Mon Sep 17 00:00:00 2001 From: EnragedAntelope <176548309+EnragedAntelope@users.noreply.github.com> Date: Sat, 8 Nov 2025 09:02:46 -0500 Subject: [PATCH] Refactor ConstrainResolution class and methods --- nodes.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/nodes.py b/nodes.py index 3b30c08..f6e7a0e 100644 --- a/nodes.py +++ b/nodes.py @@ -79,9 +79,9 @@ class ConstrainResolution(io.ComfyNode): ), # Constraint behavior - io.Enum.Input( - ConstraintMode, + io.Input( "constraint_mode", + ConstraintMode, default=ConstraintMode.MIN_RES, tooltip=( "How to handle conflicts when extreme aspect ratios make it impossible to satisfy both min and max.\n" @@ -99,9 +99,9 @@ class ConstrainResolution(io.ComfyNode): "Disable if preserving the entire image is more important than exact dimensions." ) ), - io.Enum.Input( - CropPosition, + io.Input( "crop_position", + CropPosition, default=CropPosition.CENTER, tooltip=( "Where to crop from when 'Crop as Required' is enabled.\n" @@ -179,7 +179,7 @@ class ConstrainResolution(io.ComfyNode): min_res: int, max_res: int, multiple_of: int, - constraint_mode: str + constraint_mode: ConstraintMode ) -> Tuple[int, int]: """Calculate optimal dimensions based on constraints""" if height == 0 or width == 0: @@ -255,7 +255,7 @@ class ConstrainResolution(io.ComfyNode): image: torch.Tensor, target_width: int, target_height: int, - position: str + position: CropPosition ) -> torch.Tensor: """ Crop image to exact target dimensions from specified position. @@ -280,19 +280,19 @@ class ConstrainResolution(io.ComfyNode): return image # Calculate crop coordinates based on position - if position == "center": + if position == CropPosition.CENTER: left = width_diff // 2 top = height_diff // 2 - elif position == "top": + elif position == CropPosition.TOP: left = width_diff // 2 top = 0 - elif position == "bottom": + elif position == CropPosition.BOTTOM: left = width_diff // 2 top = height_diff - elif position == "left": + elif position == CropPosition.LEFT: left = 0 top = height_diff // 2 - elif position == "right": + elif position == CropPosition.RIGHT: left = width_diff top = height_diff // 2 else: