mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix incorrect bounding-box calculation in ImageResizer
- Under some circumstances, the image resizer was fitting the wrong dimension to the user-provided bounding box when an init image provided. - Closes #1470.
This commit is contained in:
parent
38b9658c15
commit
398a9bc0c6
@ -1072,14 +1072,8 @@ class Generate:
|
||||
print(
|
||||
f'>> image will be resized to fit inside a box {w}x{h} in size.'
|
||||
)
|
||||
if image.width > image.height:
|
||||
h = None # by setting h to none, we tell InitImageResizer to fit into the width and calculate height
|
||||
elif image.height > image.width:
|
||||
w = None # ditto for w
|
||||
else:
|
||||
pass
|
||||
# note that InitImageResizer does the multiple of 64 truncation internally
|
||||
image = InitImageResizer(image).resize(w, h)
|
||||
image = InitImageResizer(image).resize(width=w, height=h)
|
||||
print(
|
||||
f'>> after adjusting image dimensions to be multiples of 64, init image is {image.width}x{image.height}'
|
||||
)
|
||||
|
@ -31,10 +31,10 @@ class InitImageResizer():
|
||||
elif not width: # width missing
|
||||
width = int(height*ar)
|
||||
|
||||
# rw and rh are the resizing width and height for the image
|
||||
# they maintain the aspect ratio, but may not completelyl fill up
|
||||
# the requested destination size
|
||||
(rw,rh) = (width,int(width/ar)) if im.width>=im.height else (int(height*ar),height)
|
||||
w_scale = width/im.width
|
||||
h_scale = height/im.height
|
||||
scale = min(w_scale,h_scale)
|
||||
(rw,rh) = (int(scale*im.width),int(scale*im.height))
|
||||
|
||||
#round everything to multiples of 64
|
||||
width,height,rw,rh = map(
|
||||
|
Loading…
x
Reference in New Issue
Block a user