[英]PHP imagejpeg does not work
Using this logic to resize and print an image: 使用此逻辑来调整大小并打印图像:
$image_path="path/to/image.extension";
$image_path=imagecreatefromjpeg($image_path);
$width=imagesx($image_path);
$height=imagesy($image_path);
$new_image=imagecreatetruecolor($w, $h);
imagecopyresampled($new_image,$image_path,0,0,0,0,$w,$h,$width,$height);
header('Content-Type: image/jpeg');
imagejpeg($new_image,100);
imagedestroy($new_image);
But I am getting image missing icon as output. 但是我得到的图像缺少图标作为输出。 What is the mistake I do? 我做错了什么? I have tried printing the variables $width
and $height
and it prints the dimension of source image. 我尝试打印变量$width
和$height
并且它打印源图像的尺寸。 So the path is correct. 所以路径是正确的。
What could be the error? 可能是什么错误?
The mistake was in the line imagejpeg($new_image,100);
错误是在行imagejpeg($new_image,100);
It must be imagejpeg($new_image);
它必须是imagejpeg($new_image);
Quality must not be included in that, if not intended to save. 如果不打算保存,则质量中不能包括质量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.