From 43bf24a89137c97650d4cc782fde1d25c26967f8 Mon Sep 17 00:00:00 2001 From: GiusTex <112352961+GiusTex@users.noreply.github.com> Date: Sat, 5 Oct 2024 15:59:23 +0200 Subject: [PATCH] try fixing cannot access local variable 'new_width' --- nodes.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nodes.py b/nodes.py index 7bc58a3..b7f813b 100644 --- a/nodes.py +++ b/nodes.py @@ -60,6 +60,12 @@ class PadImageForDiffusersOutpaint: new_height = int(source.height * scale_factor) source = source.resize((new_width, new_height), Image.LANCZOS) + if source.width == target_size[0] and source.height != target_size[1]: + scale_factor = min(target_size[0] / source.width, target_size[1] / source.height) + new_width = target_size[0] + new_height = int(source.height * scale_factor) + source = source.resize((new_width, new_height), Image.LANCZOS) + if not can_expand(source.width, source.height, target_size[0], target_size[1], alignment): alignment = "Middle" # Calculate margins based on alignment