improve resolution handling (#396)

* improve resolution handling

* improve resolution handling

* improve resolution handling

* improve resolution handling
This commit is contained in:
lllyasviel
2023-09-16 13:21:35 -07:00
committed by GitHub
parent 6adc771888
commit ceee6dfd73
3 changed files with 57 additions and 22 deletions
+19
View File
@@ -6,6 +6,25 @@ import os
from PIL import Image
def image_is_generated_in_current_ui(image, ui_width, ui_height):
H, W, C = image.shape
if H < ui_height:
return False
if W < ui_width:
return False
k1 = float(H) / float(W)
k2 = float(ui_height) / float(ui_width)
d = abs(k1 - k2)
if d > 0.01:
return False
return True
LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS)