

def resizeCrop(img, width, height, center, force):
    '\n    # Esto no hace nada perceptible\n    RATIO = 2\n    while img.size[0] / RATIO > width or img.size[1] / RATIO > height:\n        img = img.resize((int(img.size[0]/RATIO), int(img.size[1]/RATIO)), pil.ANTIALIAS)\n    '
    max_width = width
    max_height = height
    if (not force):
        img.thumbnail((max_width, max_height), pil.ANTIALIAS)
    else:
        (src_width, src_height) = img.size
        src_ratio = (float(src_width) / float(src_height))
        (dst_width, dst_height) = (max_width, max_height)
        dst_ratio = (float(dst_width) / float(dst_height))
        if (dst_ratio < src_ratio):
            crop_height = src_height
            crop_width = (crop_height * dst_ratio)
            x_offset = (float((src_width - crop_width)) / 2)
            y_offset = 0
        else:
            crop_width = src_width
            crop_height = (crop_width / dst_ratio)
            x_offset = 0
            y_offset = (float((src_height - crop_height)) / 2)
        (center_x, center_y) = center.split(',')
        center_x = float(center_x)
        center_y = float(center_y)
        x_offset = min(max(0, ((center_x * src_width) - (crop_width / 2))), (src_width - crop_width))
        y_offset = min(max(0, ((center_y * src_height) - (crop_height / 2))), (src_height - crop_height))
        img = img.crop((int(x_offset), int(y_offset), (int(x_offset) + int(crop_width)), (int(y_offset) + int(crop_height))))
        img = img.resize((int(dst_width), int(dst_height)), pil.ANTIALIAS)
    return img

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