fix new_width not found
This commit is contained in:
@@ -47,6 +47,13 @@ class PadImageForDiffusersOutpaint:
|
||||
source=im.convert('RGB')
|
||||
target_size = (width, height)
|
||||
|
||||
# Raise an error.
|
||||
if source.width == width and source.height == height:
|
||||
raise ValueError(f'Input image size is the same as target size, resize input image or change target size.')
|
||||
|
||||
# Initialize new_width and new_height
|
||||
new_width, new_height = source.width, source.height
|
||||
|
||||
# Upscale if source is smaller than target in both dimensions
|
||||
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)
|
||||
@@ -60,12 +67,6 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user