code: def scale_min(im, targ, interpolation=cv2.INTER_AREA):
      
      r,c,*_ = im.shape
      ratio = targ/min(r,c)
      sz = (scale_to(c, ratio, targ), scale_to(r, ratio, targ))
      return cv2.resize(im, sz, interpolation=interpolation)
docs: Scale the image so that the smallest axis is of size targ.
  
      Arguments:
          im (array): image
          targ (int): target size