fix: use better rescale

This commit is contained in:
Bryce 2022-09-24 09:01:35 -07:00 committed by Bryce Drennan
parent b69b4c770e
commit 30a80faf47

View File

@ -15,7 +15,7 @@ def pillow_fit_image_within(image: PIL.Image.Image, max_height=512, max_width=51
resize_ratio = min(max_width / w, max_height / h)
w, h = int(w * resize_ratio), int(h * resize_ratio)
w, h = map(lambda x: x - x % 64, (w, h)) # resize to integer multiple of 64
image = image.resize((w, h), resample=Image.Resampling.NEAREST)
image = image.resize((w, h), resample=Image.Resampling.LANCZOS)
return image