Drawing ordinary text
Function: imagestring()
1 |
|
imagestring() Use col color to draw the string s to the x of the image represented by image, y coordinate (this is the coordinate of the upper left corner of the string, the upper left corner of the entire image is 0, 0). If font is 1, 2, 3, 4 or 5, the built-in font is used.
Using imagestring to draw fonts is very simple. But the flaws are also very obvious. The font size is only 1 to 5, and Chinese characters are not supported.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Use the font library to draw text
Use imagestring to draw text, it is very simple. But there are several flaws. First of all: it cannot draw Chinese. In addition, the text drawn using imagestring will not be too large.
Here we use imagettftext to draw text. In addition to setting the font size, imagettftext can also set the tilt angle of the font.
Before use, we need to find some fonts in ttf format. There are many fonts in the C:\Windows\Fonts directory under the Windows system.
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 |
|
The picture effect drawn is as follows:
The above is the detailed content of PHP image processing (medium) - drawing text. For more information, please follow other related articles on the PHP Chinese website!