mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-31 22:37:15 +08:00
Update image_nodes.py
This commit is contained in:
parent
a15d79d5dc
commit
2c7e8613e0
@ -1315,15 +1315,24 @@ highest dimension.
|
|||||||
_, width, height, _ = get_image_size.shape
|
_, width, height, _ = get_image_size.shape
|
||||||
|
|
||||||
if keep_proportion:
|
if keep_proportion:
|
||||||
ratio = min(width / W, height / H)
|
# If one of the dimensions is zero, calculate it to maintain the aspect ratio
|
||||||
width = round(W * ratio)
|
if width == 0 and height != 0:
|
||||||
height = round(H * ratio)
|
ratio = height / H
|
||||||
|
width = round(W * ratio)
|
||||||
|
elif height == 0 and width != 0:
|
||||||
|
ratio = width / W
|
||||||
|
height = round(H * ratio)
|
||||||
|
elif width != 0 and height != 0:
|
||||||
|
# Scale based on which dimension is smaller in proportion to the desired dimensions
|
||||||
|
ratio = min(width / W, height / H)
|
||||||
|
width = round(W * ratio)
|
||||||
|
height = round(H * ratio)
|
||||||
else:
|
else:
|
||||||
if width == 0:
|
if width == 0:
|
||||||
width = W
|
width = W
|
||||||
if height == 0:
|
if height == 0:
|
||||||
height = H
|
height = H
|
||||||
|
|
||||||
if divisible_by > 1:
|
if divisible_by > 1:
|
||||||
width = width - (width % divisible_by)
|
width = width - (width % divisible_by)
|
||||||
height = height - (height % divisible_by)
|
height = height - (height % divisible_by)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user