<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def level(self, img, level):
 """Get image level. Parameters img : `PIL.Image` Input image. level : `int` Level number. Returns ------- `PIL.Image` Converted image. """

        if level < self.levels - 1:
            width, height = img.size
            scale = reduce(lambda x, y: x * y,
                           islice(self.level_scale, level, self.levels))
            img = img.resize((width // scale, height // scale), self.scale)
        return img