title: Resize panoramic image to fixed size
body: <p>I want to resize the images to fixed width and height (i.e. 150px). However, theres a problem, if there is lots of difference in height and width of original photo (for example, panoramic photo), the resized thumbnail looks bad. Is there any any smart solution to resize the photos to a fixed width and height? For example, please have a look at this 
  image:
  <img src="https://i.stack.imgur.com/Erhs2.png" alt="enter image description here"></p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
      $params = getimagesize($tempFile);
      $width = $params[0];
      $height = $params[1];
  
      $newwidth=150;
      $newheight= 150;
      $tmp=imagecreatetruecolor($newwidth,$newheight);
  
      imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
      imagejpeg($tmp,$img_name,80);
  
      imagedestroy($src);
      imagedestroy($tmp); 
  ?&gt;
  </code></pre>
  
  <p>Is there any smart way to resize the images in smart way?
  Thanks.</p>