This is my first approach to GD. I am trying to implement resizing and cropping using jcrop jquery plugin. I still cannot figure out how to save the image that I cropped. There is not much jcrop on the site. here is my code:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = 'demo_files/flowers.jpg';
$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,null,$jpeg_quality);
exit;
}
What should I do with imagejpeg ($ dst_r, null, $ jpeg_quality) to actually write the image file and save its path in my db?
Thanks in advance.
Mauro
source
share