imagecopy在 php 中重新采样 ->目标文件
我正在使用 jCrop 和 CodeIgniter,尝试制作图像上传器。
所以我有我的图像文件夹和临时文件夹。
我上传到我的临时文件夹,然后使用裁剪器显示上传的图像。
当我提交表单时,我转到我的 php 并使用 jCrop 提供的代码:
$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);
也不在这里或其他任何地方,我看到如何定义目标图像路径和文件名。
我想将原始文件夹保留在临时文件夹中,并在父文件夹中创建调整大小的文件夹。
有人可以帮我吗?
i'm using jCrop and CodeIgniter, trying to make an image uploader.
So i have my image folder and inside a temp folder.
I make the upload to my temp folder and then display the uploaded image with the cropper.
When i submit the form, i go to my php and use the code provided by jCrop:
$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);
Nor in here, or anywhere else, i see how to define the destination image path and filename.
I want to keep the original one in the temp folder and create the resized one in the parent folder.
Can someone help me please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您会发现
imagejpeg()
的手册页很有启发性 ——第二个参数(在示例代码中为null
)是目标文件名。请注意,一旦脚本终止,临时目录中的副本可能会消失。
You'll find the manual page for
imagejpeg()
enlightening -- the second argument, which isnull
in your example code, is the destination file name.Just be aware that the copy in the temporary directory may disappear once the script terminates.