<?php
$image = imagecreatetruecolor(300, 100);
imagesavealpha($image, true);
$trans_colour = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $trans_colour);
$font_color = imagecolorallocate($image, 255, 0, 0);
$font = 'C:/Windows/Fonts/msyhl.ttc'; $font_size = 40;
$text = "京东";
$bbox = imagettfbbox($font_size, 0, $font, $text);
$width = $bbox[2] - $bbox[0];
$height = $bbox[1] - $bbox[7];
$x = (imagesx($image) - $width) / 2;
$y = (imagesy($image) + $height) / 2;
imagettftext($image, $font_size, 0, $x, $y, $font_color, $font, $text);
header('Content-Type: image/png');
imagepng($image,'k.png');
imagedestroy($image);
?>