code: def outbound_sizes(cls, original_width, original_height, target_width, target_height):
          
          if target_width <= original_width and target_height <= original_height:
              k = original_width / float(original_height)
              k_w = original_width / float(target_width)
              k_h = original_height / float(target_height)
  
              if k_w > k_h:
                  target_width = int(target_height * k)
              else:
                  target_height = int(target_width / k)
          else:
              target_width = original_width
              target_height = original_height
  
          return target_width, target_height
docs: Calculate new image sizes for outbound mode
          :param original_width: int
          :param original_height: int
          :param target_width: int
          :param target_height: int
          :return: tuple(int, int)