title: How can I crop an image properly with php?
body: <p>I am trying to crop an image on <code>PHP</code>. I saw that there is a function for doing that on <code>PHP</code>: <a href="http://php.net/manual/en/function.imagecrop.php" rel="nofollow">imagecrop</a>. Here is the code in which I am trying to crop the image.</p>
  
  <pre><code>$image = imagecreatefromjpeg(//Path of the image);
  $croppedImage = imagecrop($image, array("x"=&gt;0,"y"=&gt;0,"width"=&gt;100,"height"=&gt;100));
  imagejpeg($croppedImage, //Path in which the image will be stored); 
  </code></pre>
  
  <p>Here I want that the crop of the image starts in the left corner of the image and get the values of width and height that I put above.</p>
  
  <p>But it just resize my image, not crop it. What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I tried also with the function <a href="http://php.net/manual/en/function.imagecopyresampled.php" rel="nofollow">imagecopyresampled</a>. Here it is what I have tried:</p>
  
  <pre><code>dst_image(Destination image link resource) = newImage; //Here the new image that I want to create.
  
  src_image(Source image link resource) = image; //Here the original image.
  
  //Here 0,0 because I want that the new image crop starts in the left corner of the original image.
  
  dst_x(x-coordinate of destination point) = 0;
  
  dst_y(y-coordinate of destination point) = 0;
  
  //Here 0,0 because I want that the crop starts on the 0,0 of the original image
  
  src_x(x-coordinate of source point) = 0;
  
  src_y(y-coordinate of source point) = 0;
  
  dst_w(Destination width) = 150; //The new width of the crop image.
  
  dst_h(Destination height)  = 150; //The new height of the crop image.
  
  src_w(Source width) = 500; //The original width of the image.
  
  src_h(Source height) = 500; //The original height of the image.
  </code></pre>
  
  <p>So finally the function will be like:</p>
  
  <pre><code>$b = imagecopyresampled ($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w , $dst_h , $src_w , $src_h ); 
  </code></pre>
  
  <p>I just have problems in this function it is why avoid the rest (save and imagetruecolor and the rest...)</p>
  
  <p><strong>This function give to me the result expected but the new image it is black, why?</strong></p>
  
  <p>Thanks in advance!</p>