code: def smart_crop(crop_w, crop_h, image_path):
      
      cropping = face_and_energy_detector(image_path)
      img = Image.open(image_path)
      w, h = img.size
      scaled_size = get_crop_size(crop_w, crop_h, *img.size)
      gravity_x = int(round(scaled_size[0] * cropping.gravity[0]))
      gravity_y = int(round(scaled_size[1] * cropping.gravity[1]))
      if scaled_size[0] == crop_w:
          # find the top and bottom crops
          crop_top, crop_bot = calc_subrange(scaled_size[1], crop_h, gravity_y)
          return scaled_size, Rect(left=0, top=crop_top, right=crop_w, bottom=crop_bot)
      else:
          # find the right and left crops
          crop_left, crop_right = calc_subrange(scaled_size[0], crop_w, gravity_x)
          return scaled_size, Rect(left=crop_left, top=0, right=crop_right, bottom=crop_h)
docs: Return the scaled image size and crop rectangle