class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
$srcx = $handle->image_src_x; $srcy = $handle->image_src_y; $handle->image_precrop = array($y1, $srcx - $x2, $srcy - $y2, $x1);
Thank you!
This way, is correct.
Without these lines, the second time cropping, the image_src_x and image_src_y, what not like first time.