$charFactor = 1; $textLen = mb_strlen($text); $imageWidth = $textLen * $charWidth * $charFactor; $imageHeight = $fontsize; $logoimg = imagecreatetruecolor($imageWidth, $imageHeight); imagealphablending($logoimg, false); imagesavealpha($logoimg, true); $col = imagecolorallocatealpha($logoimg, 255, 255, 255, 127); imagefill($logoimg, 0, 0, $col); $white = imagecolorallocate($logoimg, $rgbColors[0], $rgbColors[1], $rgbColors[2]); //for font color $x = 0; $y = $fontsize; $angle = 0; $bbox = imagettftext($logoimg, $fontsize, $angle, $x, $y, $white, $font, $text); //fill text in your image $boxWidth = $bbox[4] - $bbox[0]; $boxHeight = $bbox[7] - $bbox[1]; imagedestroy($logoimg); //-------------------------------------------- // CREATE THE PNG //-------------------------------------------- $imageWidth = abs($boxWidth); $imageHeight = abs($boxHeight); $logoimg = imagecreatetruecolor($imageWidth, $imageHeight); imagealphablending($logoimg, false); imagesavealpha($logoimg, true); $col = imagecolorallocatealpha($logoimg, 255, 255, 255, 127); imagefill($logoimg, 0, 0, $col); $white = imagecolorallocate($logoimg, $rgbColors[0], $rgbColors[1], $rgbColors[2]); //for font color $x = 0; $y = $fontsize; $angle = 0; imagettftext($logoimg, $fontsize, $angle, $x, $y, $white, $font, $text); //fill text in your image imagepng($logoimg); //save your image at new location $target imagedestroy($logoimg);
This is some red text.
This is some text! These are red words .<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="50"
Hello, world!
// code for coloring
// code for coloring
// code for coloring
// code for coloring
+ this will be highlighted in green
- this will be highlighted in red
color=gray
Some green text Some green text
文档请查看 http://blog.csdn.net/u012551350/article/details/52026740
http://blog.csdn.net/u012551350/article/details/52026740
欢迎加入478720016群来帮助更多的人。