I can crop my images and click on crop. but then something goes wrong, because i don't know exactly how to save this image.
I use imagecreatefromjpeg from php. this code look like this:
<?php
SESSION_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$targ_w = 200;
$targ_h = 400;
$jpeg_quality = 90;
$src = $_SESSION['target_path'];
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
$targ_w,$targ_h,$_POST['w'],$_POST['h']);
//header('Content-type: image/jpeg');
imagejpeg($dst_r, 'uploads/cropped/' . 'filename');
exit;
}
?>
My php code for saving the original image looks like this:
<?php
session_start();
$target = "uploads/";
$target = $target . basename( $_FILES['filename']['name']) ;
$_SESSION['target_path'] = $target;
$ok=1;
if(move_uploaded_file($_FILES['filename']['tmp_name'], $target))
{
echo "De afbeelding *". basename( $_FILES['filename']['name']). "* is geupload naar de map 'uploads'";
}
else {
echo "Sorry, er is een probleem met het uploaden van de afbeelding.";
}
?>
how do i save the cropped image? and is there a way to save the cropped image by overwriting the original so i get only the cropped image?
thanks in advance.
EDIT: I can save 1 photo now. i edited my code to: imagejpeg($dst_r, 'uploads/cropped/' . $filename .'boek.jpg'); But i have to make a function who can save multiple files with each another name. and maybe overwrite the original image, who is saved in 'uploads/'
uploads\cropped
-- exist? – Laceefalse
on failure. If you do something likeif (! $img_r = imagecreatefromjpeg($src)) die ('here is the problem');
with all your calls you'll find the problem soon enough. – Lacee