

def resizeScale(img, width, height, force):
    (src_width, src_height) = img.size
    src_ratio = (float(src_width) / float(src_height))
    if force:
        max_width = width
        max_height = height
    else:
        max_width = min(width, src_width)
        max_height = min(height, src_height)
    dst_width = max_width
    dst_height = (dst_width / src_ratio)
    if (dst_height > max_height):
        dst_height = max_height
        dst_width = (dst_height * src_ratio)
    img = img.resize((int(dst_width), int(dst_height)), pil.ANTIALIAS)
    return img

dataset/ETHPy150Open francescortiz/image/image/utils.py resizeScale/original