1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <?php header('Content-Type: image/png');
$width = 144; $height = 144;
$image = imagecreatetruecolor($width, $height); $white = imagecolorallocate($image, 255, 255, 255); imagefill($image, 0, 0, $white);
$textColor = imagecolorallocate($image, 255, 0, 0); $text = "双色选号";
$fontPath = './skurri.ttf'; $fontSize = 24;
$textInfo = imagettfbbox($fontSize, 0, $fontPath, $text); $textWidth = $textInfo[2] - $textInfo[0]; $textHeight = $textInfo[1] - $textInfo[7];
$x = ($width - $textWidth) / 2; $y = ($height - $textHeight) / 2 + $textHeight;
imagettftext($image, $fontSize, 0, $x, $y, $textColor, $fontPath, $text);
imagepng($image); imagedestroy($image); ?>
|