【发布时间】:2021-08-01 06:27:20
【问题描述】:
我有以下课程
public static function resize_imagejpg($file, $new_width, $new_height) {
list($orig_width, $orig_height) = getimagesize($file);
$width = $orig_width;
$height = $orig_height;
# taller
if ($height > $new_width) {
$width = ($new_height / $height) * $width;
$height = $new_height;
}
# wider
if ($width > $new_width) {
$height = ($new_width / $width) * $height;
$width = $new_width;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($file);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $orig_width, $orig_height);
return $image_p;
}
我叫它
$tmp = Url::resize_imagejpg('uploads/temp.jpg', 300, 300);
然后
copy($tmp, 'uploads/thumb.jpg');
但我收到以下错误
2021 年 5 月 10 日晚上 21:30 出错 - copy() 期望参数 1 是有效路径,/home 中给出的资源....
我知道文件是他们的,我知道它是一张图片,因为我已经在编辑器中打开了它,但我不断收到错误消息
请帮忙!!!
【问题讨论】:
标签: php image-processing copy