PHP imagepng文件输出正常,但在浏览器上显示为空白
我有以下代码:PHP imagepng文件输出正常,但在浏览器上显示为空白,php,Php,我有以下代码: public function generateImage ($product_path, $layer1_path, $layer2_path, $result_path, $price) { $product = imagecreatefromjpeg($product_path); $dest = imagecreatefrompng($layer1_path); $src = imagecreatefrompng($layer2_path);
public function generateImage ($product_path, $layer1_path, $layer2_path, $result_path, $price) {
$product = imagecreatefromjpeg($product_path);
$dest = imagecreatefrompng($layer1_path);
$src = imagecreatefrompng($layer2_path);
imagecopymerge($dest, $product, 560, 67, 0, 0, 574, 494, 100);
imagecopymerge($dest, $src, 400, 170, 0, 0, 220, 220, 100);
header('Content-Type: image/png');
imagepng($dest, $result_path);
imagedestroy($dest);
imagedestroy($src);
return $result_path;
}
当我运行该代码时,它会在我的浏览器上显示:
输出文件实际上存在于我想要的路径上。但是我需要$result\u path
作为输出,而不是给出这个黑屏
如何获得路径,而不是这个黑屏?谢谢。您是否在任何地方回显生成的图像?
$socmed=new SocialMedia()$socmed->generateImage($product\U path、$fb\U layer1\U path、$layer2\U path、$fb\U card\U path、$price)代码>我没有回显结果。那就是你的问题了。您正在生成图像,但没有将其发送到浏览器。如果我只想保存图像文件并获取路径,该怎么办?可能吗?