Learning points:
1. Create an image
2. Simple small cases
In PHP5, processing of dynamic images is much easier than before. PHP5 contains GD extension in the php. ini file
Expand the package. You only need to remove the corresponding comments of the GD extension package to use it normally. The GD library contained in PHP5 is upgraded.
GD2 library, which contains some useful JPG functions that support true color image processing.
Generally, generated images are stored in the PHP document format. However, you can insert HTML images to SRC.
To directly obtain dynamic images. For example, verification code, watermark, and thumbnail.
1. Create an image
General process for creating images:
1) set the header to tell the browser the MIME type you want to generate.
2) create an image region based on which operations will be performed in the future.
3) Fill the background in the blank image area.
4) Draw the input text of the graphic outline on the background.
5). Output the final image.
6) Clear all resources.
7). Call images on other pages.
Set the header to specify the MIME output type
<?('Content-Type: image/png'?>
Create a blank image area
<? = imagecreatetruecolor(200,200?>
Fill background in blank image area
<? = imagecolorallocate(,0,102,255,0,0,?>
Draw a graphical outline input text on the background
<? = imagecolorallocate(,255,255,255,0,0,200,200,,200,0,0,200,, 5, 80, 20, "Mr.Lee", ?>
Output final image
<??>
Clear all resources
<??>
Images Created by calling other pages
Ii. Simple small cases
Simple Verification Code
<?('Content-type: image/png'(=0;<4;++.=((0,15 = imagecreatetruecolor(75,25 = imagecolorallocate(,0,102,255 = imagecolorallocate(,255,255,255,0,0,,5,20,4,,?>
Load existing images
<?('Content-Type:image/png'('__DIR__',().'\\' = imagecreatefrompng(__DIR__.'222.png' = imagecolorallocate(,255,255,255,3,5,5,'http://www.yc60.com',?>
Load existing system Fonts
<? = ("Gbk", "UTF-8", "Li Yanhui" = 'C: \ WINDOWS \ Fonts \ SIMHEI. ttf', 20, 0, 30, 30,?>
Image thumbnail
<?('Content-type: image/png'('__DIR__',().'\\'(, ) = (__DIR__.'222.png' = * 0.7 = * 0.7 = imagecreatetruecolor(, = imagecreatefrompng(__DIR__.'222.png', , 0, 0, 0, 0,, , , ?>
Note: This article is a video tutorial from Li Yanhui PHP. This article is intended for communication purposes only and cannot be used for commercial purposes. Otherwise, the consequences will be borne by you.