title: php - imagecopyresampled
body: <p>I'm trying to use <code>jcrop</code> to allow users to create a thumbnail of their image, it will be <code>190x190 pixels</code>.</p>
  
  <p><code>jcrop</code> seems to be working and sending me the correct coordinates. However, <code>imagecopyresampled</code> seems to be acting very unpredictably and not giving me what I expect. Here is my code:</p>
  
  <pre><code>$destWidth = $destHeight = 190;
  $jpeg_quality = 90;
  $path = Yii::app()-&gt;basePath."/../images/user/";
  $src = $path.$model-&gt;image;
  
  $img_src = imagecreatefromjpeg($src);
  $img_dest = ImageCreateTrueColor( $destWidth, $destHeight );
  
  imagecopyresampled(
  $img_dest, //destination image
  $img_src, //source image
  0, //top left coordinate of the destination image in x direction
  0, //top left coordinate of the destination image in y direction
  $_POST['x'], //top left coordinate in x direction of source image that I want copying to start at
  $_POST['y'], //top left coordinate in y direction of source image that I want copying to start at
  $destWidth, //190, thumbnail width
  $destHeight, //190, thumbnail height
  $_POST['w'], //how wide the rectangle from the source image we want thumbnailed is
  $_POST['h'] //how high the rectangle from the source image we want thumbnailed is
  );
  
  imagejpeg($img_dest,$path."thumbs/test.jpg",$jpeg_quality);
  </code></pre>
  
  <p>I'm seriously at a loss, I've checked that the four <code>$_POST</code> variables are all coming in correctly, but for some reason I can't get a proper thumbnail. All I can tell for sure is that the thumbnail is usually zoomed in too much and that the top left corner I want it to start from isn't being used.</p>