code: def level(self, img, level):
          
          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
docs: Get image level.
  
          Parameters
          ----------
          img : `PIL.Image`
              Input image.
          level : `int`
              Level number.
  
          Returns
          -------
          `PIL.Image`
              Converted image.