On my page I use a script to get a new image:
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = $_POST['image'];
$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);
Currently, the script receives $_POST data, extracts an image from it, then displays that image back to the user.
Now I would like to add logic to save the image in a file, but I don't know how to go about it. Any hints will be appreciated.