Header ("Content-type:image/jpeg");
function Makethumb ($srcFile, $text, $size =12, $R =0, $G =0, $B =0) {
if (! $text) {
$text = ' Welcome to imbbs.cn ';
$size = 20;
$R = 255;
}
$data = getimagesize ($srcFile,& $info);
Switch ($data [2]) {
Case 1://Picture type, 1 is GIF graph
$im = @ImageCreateFromGIF ($srcFile);
Break
Case 2://Picture type, 2 is JPG graph
$im = @imagecreatefromjpeg ($srcFile);
Break
Case 3://Picture type, 3 is PNG graph
$im = @ImageCreateFromPNG ($srcFile);
Break
}
$srcW =imagesx ($im);
$srcH =imagesy ($im);
$ni = Imagecreatetruecolor ($srcW, $srcH);
Imagecopyresampled ($ni, $im, 0,0,0,0, $srcW, $srcH, $srcW, $srcH);
$font = "2.ttf";
$textcolor = Imagecolorallocate ($ni, $R, $G, $B); Set text color
$i = 0;
$txt = "";
$len =ceil ((12*22)/$size);
$lgg =ceil (($size *16)/12)-1;
while (strlen ($txt) >0| |! $i) {
$start = $len * $i;
$kk =ceil ($size *13/12);
$KK = 13;
$txt =substr ($text, $start, $len);
$hei = $i * $lgg + $kk;
Imagettftext ($ni, $size, 0, 8, $hei, $textcolor, $font, $txt); Write the text with a font
$i + +;
}
Imagejpeg ($ni);
}
if (! $size | | $size <1) $size = 12;
Makethumb ("Face.jpg", $text, $size, $R, $G, $B);
?>
The above describes the PHP code at any time to paste their own pictures and text PHP code, including the content of the PHP code, I hope that the PHP tutorial interested in a friend to help.