<?php
// **************************************** //
Function: Add text to a picture
Parameters: $img picture file name
$new _img Save the picture file name, if blank indicates no save picture
$text String Contents
Text_size string Size
Text_angle Font string Output angle
text_x string Output x coordinates
text_y string output y-coordinate
$text _font Font file name
$r, $g, $b string color RGB value
// **************************************** //
function Img_text ($img, $new _img, $text, $text _size, $text _angle, $text _x, $text _y, $text _font, $r, $g, $b) {
$text =iconv ("gb2312", "UTF-8", $text);
Header ("Content-type:image/gif");
$im = @imagecreatefromstring (file_get_contents ($img)) or Die ("Open picture Failed!");
$color = Imagecolorallocate ($im, $r, $g, $b);
Imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text):
This function writes TTF (TrueType Fonts) font text to a picture.
Parameter: size is the dimension of zigzag;
Angle for the angle of the font, clockwise calculation, 0 degrees to the level (from left to right), 90 degrees to the top of the text;
X,y two parameter is the coordinate value of the text (the origin point is upper left corner);
Col is the color of the word;
Fontfile is the name of the font file;
Text is the string content.
Imagettftext ($im, $text _size, $text _angle, $text _x, $text _y, $color, $text _font, $text);
if ($new _img== ""):
Imagegif ($im); Do not save pictures, show only
Else
Imagegif ($im, $new _img); Save picture, but not show
endif
Imagedestroy ($im); End graphics, freeing up memory space
}
?>