[英]saving imagejpeg output the file
我在这里缺少什么吗? 如果我更改imagejpeg($thumb, $newImage);
到imagejpeg($thumb);
它回显了许多不可读的字符。 缩略图目录存在。
我的最终目的是复制较低质量的图像。
$filename = $imageDirectory . '/1.jpg';
$percent = 0.5;
$newImage = $imageDirectory . '/thumbs/1.jpeg';
echo "image: <br>";
echo $filename;
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb, $newImage);
更新:我现在意识到第二个参数必须是具有新名称的图像位置。 所以...我已经重新定义了$ newImage。 路径很好...如果我手动将名为1.jpg的图像上传到该位置,则该路径中存在该图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.