title: OpenCV Resize by Filling
body: <p>I am trying to perform some image pre-processing for a Python/OpenCV application I am working on.  I have a very simple function which loads an image from the file, and resizes it to a certain size:</p>
  
  <pre class="lang-python prettyprint-override"><code>def get_im(path):
      img = cv2.imread(path, cv2.IMREAD_COLOR)
      img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
      img = cv2.resize(img, (IMG_ROW, IMG_COL))
      img = np.array(img)
      img = img.astype('float32')
      img /= 255
      return img
  </code></pre>
  
  
  
  <p>While this resizes my images, when it does so it alters the aspect ratio of the image.  How can I (preferably using OpenCV) scale the images to fit within a certain size (IMG_ROW, IMG_COL) without altering the aspect ratio?</p>