apple
apple

Reputation: 13

Saving cropped file

$row = mysql_fetch_array($result);
$src1 = $row['file_name'];
$targ_w = $targ_h = 350;
$jpeg_quality = 90;
$img_r = imagecreatefromjpeg($src1);
$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/jpg');
imagejpeg($dst_r,null,$jpeg_quality);

How to go about saving file for this example? this is the source file name, $src1 = $row['file_name']; I can only preview the file, but not save it .

Upvotes: 0

Views: 133

Answers (2)

Martin.
Martin.

Reputation: 10529

Second parameter of imagejpeg is save path.

imagejpeg($dst_r, $src1,$jpeg_quality);

Upvotes: 2

Ry-
Ry-

Reputation: 224906

Pass a filename to imagejpeg:

imagejpeg($dst_r, $src1, $jpeg_quality);

Upvotes: 0

Related Questions