old_contents: from PIL import Image
  
  def resizeImage(im, width, height):
      originalW, originalH = im.size
      originalRatio = originalW / float(originalH)
      ratio = width / float(height)
  
      newW, newH = int(width), int(height)
  
      if (ratio < originalRatio):
          newH = int(width / originalRatio)
      else:
          newW = int(height * originalRatio)
  
      return im.resize((newW, newH), Image.ANTIALIAS)
  
  def loadImage(path):
      try:
          return Image.open(path)
      except FileNotFoundError:
          print("There is no such image exits.")
  
  if __name__ == "__main__":
      img = loadImage("./img/mao.jpg")
      # print(len(list(resizeImage(img, 100, 100).getdata())))
      img = resizeImage(img, 100, 100)
      print(img.size)
  
new_contents: from PIL import Image
  
  def resizeImage(im, width, height):
      originalW, originalH = im.size
      originalRatio = originalW / float(originalH)
      ratio = width / float(height)
  
      newW, newH = int(width), int(height)
  
      if (ratio < originalRatio):
          newH = int(width / originalRatio)
      else:
          newW = int(height * originalRatio)
  
      return im.resize((newW*2, newH), Image.ANTIALIAS)
  
  def loadImage(path):
      try:
          return Image.open(path)
      except FileNotFoundError:
          print("There is no such image exits.")
  
  if __name__ == "__main__":
      img = loadImage("./img/mao.jpg")
      # print(len(list(resizeImage(img, 100, 100).getdata())))
      img = resizeImage(img, 100, 100)
      print(img.size)
  
subject: change width of resizing