title: How to resize image and maintain aspect ratio
body: <p>I have an image of a puzzle piece that i need to resize in order for both the pieces I need to compare to have the same size. I have used the following codes to resize my image. The problem is the length of the line in the image 1 is 187 and after resizing the length of the line in image 2 is 194. intended output is for them to be same</p>
  
  <pre><code>ratio = math.hypot(x2 - x1, y2 - y1) / math.hypot(x4 - x3, y4 - y3)
  print("img1", math.hypot(x2 - x1, y2 - y1),"img 2", math.hypot(x4 - x3, y4 - y3)*ratio)
  
  n = int(ratio * new_img_2.shape[0])
  img = cv2.resize(new_img_2, (n, n), cv2.INTER_CUBIC)
  </code></pre>