Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何保存PHP图像处理的输出_Php - Fatal编程技术网

如何保存PHP图像处理的输出

如何保存PHP图像处理的输出,php,Php,我不确定这个函数是否符合我的预期,但我需要的是在文件夹中创建一个图像的缩略图 $filename = '../images/' . $new_name; header('Content-Type: image/jpeg'); list($width, $height) = getimagesize($filename); $new_width = $width / $height; $new_height = 250 / $new_width; $new_height = round(

我不确定这个函数是否符合我的预期,但我需要的是在文件夹中创建一个图像的缩略图

$filename = '../images/' . $new_name;

header('Content-Type: image/jpeg');

list($width, $height) = getimagesize($filename);

$new_width = $width / $height;

$new_height = 250 / $new_width;

$new_height = round($new_height);

$image_p = imagecreatetruecolor(250, $new_height);
$image_s = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image_s, 0, 0, 0, 0, 250, $new_height, $width, $height);

imagejpeg($image_p, null, 100);
因此,我需要将最终结果保存到文件夹中,但不要覆盖原始图像。我在上找到了这个函数,但我不知道如何保存图像

imagejpeg($image_p, "path/to/dir/image.jpg", 100);

就这些。

thanx一百万!=)当图像加载到服务器时,我在尝试运行函数时创建缩略图时遇到了真正的问题。。。然后决定最好在上传后再运行。它会影响上传/处理的速度吗?当图像未完全加载到服务器上时,您无法处理它。服务器上的处理在实例中进行。你真正需要关心的唯一速度分隔符是上传速度。这里,您的internet连接和文件大小是决定因素。但是你对此无能为力。