<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def keep_file(self, task, response, min_size=None, max_size=None):
 """Decide whether to keep the image Compare image size with ``min_size`` and ``max_size`` to decide. Args: response (Response):
 response of requests. min_size (tuple or None):
 minimum size of required images. max_size (tuple or None):
 maximum size of required images. Returns: bool: whether to keep the image. """

        try:
            img = Image.open(BytesIO(response.content))
        except (IOError, OSError):
            return False
        task['img_size'] = img.size
        if min_size and not self._size_gt(img.size, min_size):
            return False
        if max_size and not self._size_lt(img.size, max_size):
            return False
        return True