title: imagecopyresampled issues...dimensions not quite right
body: <p>I'm having an issue cropping an image and thought perhaps someone out there could help. Basically, I am using jCrop to crop an image to a specified x, y, width, height and am using the following on the back-end to process the image:</p>
  
  <pre><code>&lt;?php
      $image = imagecreatefromjpeg(DOC_ROOT . '/' . $db_image-&gt;source);   
      list($image_width, $image_height) = getimagesize(DOC_ROOT . '/' . $db_image-&gt;source);
      $cf = $data-&gt;cropping_factor;
      $new_image = imagecreatetruecolor($cf * $data-&gt;crop_data['w'], $cf * $data-&gt;crop_data['h']);
      imagecopyresampled(
          $new_image, 
          $image, 
          0, //Destination x coordinate
          0, //Destination x coordinate
          intval($cf * $data-&gt;crop_data['x']), //Source X coordinate
          intval($cf * $data-&gt;crop_data['y']), //Source Y coordinate
          intval($cf * $data-&gt;crop_data['w']), //Destination W
          intval($cf * $data-&gt;crop_data['h']), //Destination H
          $image_width, //Original W
          $image_height //Original H
      );
      imagejpeg($new_image, DOC_ROOT . '/' . $db_image-&gt;source, 100);
  ?&gt;
  </code></pre>
  
  <p>Basically, this code leaves me with:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Resource id #33 //New Image
      [1] =&gt; Resource id #31 //Source Image
      [2] =&gt; 0 //Destination X
      [3] =&gt; 0 //Destination Y
      [4] =&gt; 114 //Source X
      [5] =&gt; 407 //Source Y
      [6] =&gt; 786 //New Width
      [7] =&gt; 293 //New Height
      [8] =&gt; 900 //Original Width
      [9] =&gt; 700 //Original Height
  )
  </code></pre>
  
  <p>The original image can be found here: <a href="http://cl.ly/image/3Y0l1a2h3U2S" rel="nofollow">http://cl.ly/image/3Y0l1a2h3U2S</a>. The resized image can be found here: <a href="http://cl.ly/image/0Q3J2c2q0N1j" rel="nofollow">http://cl.ly/image/0Q3J2c2q0N1j</a>.</p>
  
  <p>Thanks for the help.</p>