def scale(image, factor, resample=Image.NEAREST):
 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)

def scale ( image , factor , resample = Image . NEAREST ) : 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 )
scale an in value in the range to the range .