code: def scale(image, factor, resample=Image.NEAREST):
      """
      Returns a rescaled image by a specific factor given in parameter.
      A factor greater than 1 expands the image, between 0 and 1 contracts the
      image.
  
      :param image: The image to rescale.
      :param factor: The expansion factor, as a float.
      :param resample: An optional resampling filter. Same values possible as
         in the PIL.Image.resize function.
      :returns: An :py:class:`~PIL.Image.Image` object.
      """
      if factor == 1:
          return image.copy()
      elif factor <= 0:
          raise ValueError("the factor must be greater than 0")
      else:
          size = (
              int(round(factor * image.width)),
              int(round(factor * image.height)),
          )
          return image.resize(size, resample)
  
imports: import functools
  import operator
  from .None import Image
  from ._util import isStringType
label_desc: Use image node_id 8 for calling a global function with example usage: scale(image, factor, resample) and returns: image, image