title: Python: How to Resize Raster Image with PyQt
body: <p>I need to find a way to re-size an input raster image (such as jpg) to a specified width/height resolution (given in pixels). It would be great if PyQt while resizing a new image would keep an original image's aspect ratio (so there is no stretching but scaling only). </p>
  
  <p>src = '/Users/usrName/Images/originalImage.jpg'  (2048x1024) (rectangular image 2:1 ratio)
  dest= '/Users/usrName/Images/originalImage_thumb.jpg'  (64x64) (output image is square 1:1 ratio).</p>
  
  <p>Thanks in advance!</p>
  
  <h3>POSTED RESULTED FUNC:</h3>
  
  <p>...could be used to resize and to convert an image to any format QT supports so far... such as: 'bmp', 'gif', 'jpg', 'jpeg', 'png', 'pbm', 'tiff', 'svg', 'xbm'</p>
  
  <pre><code>def resizeImageWithQT(src, dest):
      pixmap = QtGui.QPixmap(src)
      pixmap_resized = pixmap.scaled(720, 405, QtCore.Qt.KeepAspectRatio)
      if not os.path.exists(os.path.dirname(dest)): os.makedirs(os.path.dirname(dest))
      pixmap_resized.save(dest)
  </code></pre>