testlcm / image_ops.py
michaelj's picture
change image
a4b2a07
raw
history blame
340 Bytes
from PIL import Image
def resize_pil_image(
pil_image: Image,
image_width,
image_height,
):
w, h = pil_image.size
newW = image_width
newH = int(h * newW / w)
return pil_image.convert("RGB").resize(
(
image_width,
image_height,
),
Image.Resampling.LANCZOS,
)