File size: 340 Bytes
360d274
 
 
 
 
 
 
 
cf62e43
 
 
360d274
 
 
a4b2a07
360d274
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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,
    )