I'm trying to crop an image using jcrop
and a form
. When I submit the form all the required data to crop the image, aswell as the image itself, POSTS
correctly.
Then I'll upload the original image to the server, and store the filename along with some other data in the database.
After that I start cropping, which does something. But not what I would expect.
I'm trying to crop the following image:
As you can see I´m trying to only crop the head off.
When I save the image I´ll get the following as result:
Which as I said is not what I expected.
This is my saving and cropping function:
function file_upload($x1, $y1, $x2, $y2, $w, $h){
//Bestand opslaan op de server
$filename = str_replace(' ', '', $_FILES['schilderij_toevoegen_file']['name']);
$target = '../Storage/portfolio/'.$filename;
move_uploaded_file($_FILES['schilderij_toevoegen_file']['tmp_name'], $target);
//Betand hercroppen
$copy = imagecreatefromjpeg($target);
$new = imagecreatetruecolor($w, $h);
$size = getimagesize($target);
imagecopyresampled($new, $copy, 0, 0, $x2, $y2, $w, $h, $size[0] * 0.5, $size[1] * 0.5);
imagejpeg($new, '../Storage/portfolio/crp_'.$filename);
print 'X1: '.$x1.', Y1: '.$y1.', X2: '.$x2.', Y2: '.$y2.', Width: '.$w.', Height: '.$h;
}
I'm very new with this cropping function PHP has, so I would appreciate any kind of help.
Edit: These values where used in the function above: X1: 0, Y1: 115, X2: 181, Y2: 299, Width: 181, Height: 184
The original image size is 425x348