标题内容类型image-png和透明输出

问题描述 投票:0回答:1

有什么方法可以在我们使用header("Content-Type: image/png")时创建透明图像?

<?php

    $path = "image.png";
    $image = imagecreatefrompng($path);
    header("Content-Type: image/png");
    imagepng($image);
    imagedestroy($image);

?>

编辑:输出 - >

php header gd
1个回答
1
投票

我认为它应该自动工作但似乎你必须使用imagealphablending()imagesavealpha()

$path = "image.png";
$image = imagecreatefrompng($path);

imagealphablending($image, true);
imagesavealpha($image, true);

header("Content-Type: image/png");
imagepng($image);
imagedestroy($image);
© www.soinside.com 2019 - 2024. All rights reserved.