这是我第一次用GD的方法。我正在尝试使用j笋jquery插件实现大小调整和裁剪。我还是想不出怎么保存我剪过的图像。在杰福尔网站上,没有太多关于它的内容。这是我的密码:
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;
}如何使用imagejpeg($dst_r,null,$jpeg_quality)来实际写入图像文件并将其路径保存在数据库中?
提前谢谢。
毛罗
发布于 2011-03-05 18:27:05
如果希望保存文件而不是输出文件,请执行以下两项操作:
header('Content-type: image/jpeg');imagejpeg($dst_r, 'path/to/output.jpg', $jpeg_quality);参见imagejpeg()函数在php.net/imagejpeg上的文档
https://stackoverflow.com/questions/5205821
复制相似问题