Imagettftext (image, size, angle, x, y, color, fontfile, text) means imagettftext () to draw the string text to the image represented by the image, from the coordinate x, y (0 in the upper left corner), angle, and color
The ImageTTFText function adds text watermarks to PHP images.
An ImageTTFText function contains the following parameters:
Imagettftext (image, size, angle, x, y, color, fontfile, text)
Imagettftext () draws the string text to the image, starting from x, y (0, 0 in the upper left corner), angle, color, use the TrueType font file specified by fontfile. Depending on the GD library used by PHP, if fontfile does not start with '/', '. ttf' will be added to the file name and the library will be searched to define the font path.
The coordinates represented by x and y define the basic points of the first character (probably the lower left corner of the character ). Unlike imagestring (), x and y define the upper right corner of the first character.
Angle indicates the angle. 0 degrees indicates that the text is read from left to right (three o'clock), and a higher value indicates that the text is read from bottom to top in the clockwise direction (that is, if the value is 90, the text is read from bottom to top ).
Fontfile is the file name of the TrueType font to be used.
Text is a text string that can contain a sequence of UTF-8 characters in the form of: {) to access more than the first 255 characters in the font.
Color is the color index value. Use a negative value of a color index value to disable color mixing.
For example, the following img. php source code can be used
Reference content is as follows: =============================== Img. php
Header ("Content-type: image/png "); /* Notify the browser to output the image */
// $ Im = imagecreate (400,300 ); /* If no image is specified, you can customize the image size */
$ Im = imagecreatefromjpeg ("gd04.jpg ");
$ Pink = ImageColorAllocate ($ im, 0, 0, 0 );
$ Fontfile = "C: \ WINDOWS \ Fonts \ 正 simplified. ttf "; /* $ Fontfile font path, depending on the operating system, can be simhei. ttf (), SIMKAI. TTF (entity body), SIMFANG. TTF (Imitation Song), SIMSUN. chinese fonts supported by GD, such as TTC (& */
$ Str = iconv ('gb2312', 'utf-8', 'Your desired character watermark '); /* Convert the gb2312 character set to the UTF-8 character set */
ImageTTFText ($ im, 25, 10, 140,240, $ pink, $ fontfile, $ str ); /* Add a Chinese watermark */
Imagepng ($ im ); ImageDestroy ($ im ); ?>
|
If you want to make a dynamic URL watermark
$ Str = iconv ('gb2312', 'utf-8', 'Your desired character watermark ');
Replace and use
$ Str = iconv ('gb2312', 'utf-8', $ _ REQUEST ["id"]);
You can.