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 am using imagecreatefromjpeg from php. this code is as follows:
<?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 to save the original image is as follows:
<?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 to save the cropped image? and is there a way to save the cropped image by overwriting the original to get only the cropped image?
early.
EDIT: I can save 1 photo now. I edited my code: imagejpeg ($ dst_r, 'uploads / cropped /'. $ filename.'boek.jpg '); But I have to create a function that can save multiple files with each other. and possibly overwrite the original image, which is saved in 'uploads /'
php image folder save jcrop
Kees sonnema
source share