PHP生成的png背景问题
我的php知识非常有限。。。因此,我搜索、找到并编辑了一个脚本,在png上编写文本,但透明度不存在:PHP生成的png背景问题,php,image,printing,png,generator,Php,Image,Printing,Png,Generator,我的php知识非常有限。。。因此,我搜索、找到并编辑了一个脚本,在png上编写文本,但透明度不存在: <?php $string = "username"; $string2 = "example.com"; $image = imageCreateFromPng("http://i.imgur.com/Y6hWkkW.png"); $cor = imagecolorallocate($image, 0, 0, 0); imagestring($image,5,126,22,urldeco
<?php
$string = "username";
$string2 = "example.com";
$image = imageCreateFromPng("http://i.imgur.com/Y6hWkkW.png");
$cor = imagecolorallocate($image, 0, 0, 0);
imagestring($image,5,126,22,urldecode($string),$cor);
header('Content-type: image/png');
imagepng($image,NULL);
$stype = "png";
if ($stype = "png")
{
// integer representation of the color black (rgb: 0,0,0)
$background = imagecolorallocate($image, 0, 0, 0);
// removing the black from the placeholder
imagecolortransparent($image, $background);
// turning off alpha blending (to ensure alpha channel information
// is preserved, rather than removed (blending with the rest of the
// image in the form of black))
imagealphablending($image, false);
// turning on alpha channel information saving (to ensure the full range
// of transparency is preserved)
imagesavealpha($image, true);
}
?>
理想形象
我一直在网上搜索,但找不到解决方法
如果可以的话,请花点时间帮我
非常感谢您需要“启用”透明度
$string = "username";
$string2 = "example.com";
$image = imageCreateFromPng("http://i.imgur.com/Y6hWkkW.png");
$cor = imagecolorallocate($image, 0, 0, 0);
$background = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $background);
imagealphablending($image, false);
imagesavealpha($image, true);
imagestring($image,5,126,22,urldecode($string),$cor);
header('Content-type: image/png');
imagepng($image,NULL);
请尝试以下内容:@newboyhun尝试并更新了代码,虽然没有成功,但感谢您解决了输入透明度问题,非常感谢!你能帮我提示一下吗?