def _get_size_verifier(min_x, min_y, mode):
    """
    Depending on what the user wants, we need to filter image sizes differently.
    This function generates the filter according to the user's wishes.
    :param min_x: Minimal x-coordinate length of image.
    :param min_y: Minimal y-coordinate length of image.
    :param mode: If equal to 'area': Only filter images whose area is below min_x*min_y.
                 If equal to 'individual' or anything else: Both sides of the image must be bigger than the
                 given x and y coordinates. Automatically compares long to long and short to short side.
    :returns function that decides wether an image should be kept or discarded according to the size constraints.
    """

    def by_area(width, height):
        return width * height >= min_x * min_y

    def by_both(width, height):
        long_side = max(width, height)
        short_side = min(width, height)
        long_given = max(min_x, min_y)
        short_given = min(min_x, min_y)
        return long_given <= long_side and short_given <= short_side

    def anything_goes(width, height):
        return True

    if mode == "area":
        return by_area
    elif mode == "individual":
        return by_both
    else:
        return anything_goes