After installing some third-party function libraries, you can use PHP to create and process images in combination with graphic processing techniques. In fact, you don't need a lot of geometric knowledge-because I used to fail this assignment when I was in middle school
After installing some third-party function libraries, you can use PHP to create and process images in combination with graphic processing techniques. In fact, you don't need a lot of geometric knowledge-because I used to fail this assignment when I was in middle school, but now I can use PHP to create images!
Install the GD library before creating a function for the basic image of the application.. To apply JPEG coherent image creation functions, jpeg-6b also needs to be installed. When the Type 1 font is applied to the image, t1lib must also be installed..
Here, you also need to further adjust your system settings. First install t1lib and end, then the jpeg-6b. Step 3 install the GD function library. Make sure that the above three parts are installed in order because you need to compile the GD library to apply the jpeg-6b Library. If you install the jpeg-6b first, compilation will go wrong, which will make you feel overwhelmed for a while.
After the three function libraries, reconfigure PHP. This is a typical method for easily installing the DSO version of PHP. Then performMake clean, Command, and in the current configuration prompt to participate in the following code:
-- With-gd = [/path/to/gd]
-- With-jpeg-dir = [/path/to/jpeg-6b]
-- With-t1lib = [/path/to/t1lib]
Final fulfillmentMake,Make installComplete the configuration. Restart Apache and run the phpinfo () function to check whether the new function runs normally. then you can start.
Depending on the installed GD Library version, you may have the ability to create GIF or PNG images. The point is that if you have installed a gd-1.6 or an earlier version, you can process GIF files, but not PNG files; if you have installed a gd-1.6 or a later version, you can process PNG files but not GIF files.
Creating a simple image requires several functions. I will demonstrate it as follows.
The output contains the file header of the MIME type of the image you created. PNG is used in this example.
Use ImageCreate () to create a variable to store vacant images. This function requires an image pixel size. The format is ImageCreate (x_size, y_size). For images of 250*250 pixels, see the following:
$ NewImg = ImageCreate (250,250 );
Because your image is still blank at this time, you need to fill it with some colors. However, the ImageColorAllocate () function is used to determine the name of each color based on the RGB value of the color. The function format is ImageColorAllocate ([image], [red], [green], [blue]). If the sky is blue, the application should be:
$ Skyblue = ImageColorAllocate ($ newImg, 136,193,255 );
Then, use the ImageFill () function to fill the image with the above colors. In fact, the ImageFill () function has multiple versions, such as ImageFillRectangle () and ImageFillPolygon. For the sake of simplicity, the ImageFill () function is used for color filling. the pattern is as follows:
ImageFill ([image], [start x point], [start y point], [color])
ImageFill ($ newImg, 0, 0, $ skyblue );
Finally, create the ultimate image and corrupt the image stream to release the memory and then clean up the system:
ImagePNG ($ newImg );
ImageDestroy ($ newImg);?>
Your code should look like this: