I'm trying to save an cropped image with jcrop, based on x,y,w,h. I send to my PHP file, the axis x,y and width/height, but the cropped area is wrong.
this is my php function
$axis_x = $_POST["x"];
$axis_y = $_POST["y"];
$width = $_POST["w"];
$height = $_POST["h"];
$path_foto = "imgs/3.jpg";
$targ_w = $width;
$targ_h = $height;
$jpeg_quality = 90;
$src = $path_foto;
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor($targ_w, $targ_h);
imagecopyresampled($dst_r, $img_r, 0, 0, $axis_x, $axis_y, $width, $targ_w, $targ_h, $height);
imagejpeg($dst_r, $path_foto, $jpeg_quality);
This coords is set by jcrop in an input hidden everytime when the image is redized. The problem is always crop the wrong area.
What i'm doing wrong?
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
Tryimagecopyresampled($dst_r, $img_r, 0, 0, $axis_x, $axis_y, $targ_w, $targ_h, $width, $height);
. (Notice the $width variable was moved down the line.) – Randers