2
我正在尝试将一段文本更改为图像。我无法弄清楚我的代码有什么问题,以及如何使它透明。这是我到目前为止:PHP:将文本更改为具有透明度的PNG图像的功能
<?PHP
function fsrep_imageaddress($address, $listingid) {
$font_size = 4;
$width = imagefontwidth($font_size)*strlen($address);
$height = imagefontheight($font_size);
$img = imagecreate($width,$height);
$bg = imagecolorallocate($img, 25, 25, 25);
$color = imagecolorallocate($img, 255, 255, 255);
$len = strlen($address);
$ypos = 0;
for($i=0;$i<$len;$i++){
$xpos = $i * imagefontwidth($font_size);
imagechar($img, $font_size, $xpos, $ypos, $address, $color);
$address = substr($address, 1);
}
imagepng($img, ABSPATH.'wp-content/uploads/fsrep/houses/address-'.$listingid.'.png',100);
imagedestroy($img);
}
fsrep_imageaddress(Just Testing, 12)
?>
什么是目前你的脚本做错了?你需要做的第一件事就是把'Just Testing'放在引号中,因为它是一个字符串而不是常量 –