title: PHP - cropping image with imagecopyresampled()?
body: <p>I'd like to crop an image using imagecreatetruecolor and it always crops it leaving black spaces, or the zoom is too big. I want the image to be exactly 191px wide and 90px high, so I also need to resize the image, as well as crop, because the ratio has to be kept. Well, there are some samples of the project:</p>
  
  <p><img src="https://i.stack.imgur.com/7eM8D.jpg" alt="enter image description here"></p>
  
  <p>The resize script (simplified) goes like this:</p>
  
  <pre><code>$src_img=imagecreatefromjpeg($photoTemp);    
  list($width,$height)=getimagesize($photoTemp);
  $dst_img=imagecreatetruecolor(191, 90);
  imagecopyresampled($dst_img, $src_img, 0, 0, $newImage['crop']['x'], $newImage['crop']['y'], $newImage['crop']['width'], $newImage['crop']['height'], $width, $height);
  </code></pre>
  
  <p>The $newImage['crop'] array includes:</p>
  
  <pre><code>['x'] =&gt; $_POST['inp-x']
  ['y'] =&gt; $_POST['inp-x']
  ['width'] =&gt; $_POST['inp-width']
  ['height'] =&gt; $_POST['inp-height']
  </code></pre>
  
  <p>But what I get is:</p>
  
  <p><img src="https://i.stack.imgur.com/PXM0X.jpg" alt="enter image description here"></p>
  
  <p>Anyone sees, what I'm doing wrong?</p>
  
  <p>Thanks, Mike.</p>