In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to implement graphics processing in PHP. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
1. Load GD library
GD Library is an open library of dynamically created images and open source functions that can be downloaded from the official website http://www.boutell.com/gd. At present, GD library supports GIF, PNG, JPEG, WBMP and XBM and other image formats for image processing.
GD library is installed by default in PHP 5, but to activate GD library, you must modify php.ini file. Delete the semicolon ";" before the ";extension=php_gd2.dll" option in the file, save the modified file and restart the Apache server to take effect.
2. Create a simple image
GD2 function library can be used to process various graphics and images. Creating a canvas is the first step in creating an image using the GD2 library. No matter what kind of image you create, you first need to create a canvas, and everything else will be done on this canvas. Creating a canvas in the GD2 library can be done with the imagecreate() function.
Use the imagecreate () function to create a canvas with a width of 200 pixels and a height of 60 pixels, and set the canvas color RGB (225, 66, 159), and finally output a GIF format image. The code is as follows:
3. Add text to photos using GD2 function
GD library in PHP supports Chinese, but it must pass parameters in UTF-8 format. If you use imageString() function to directly draw Chinese character string, garbled code will be displayed. This is because GD2 can only accept UTF-8 encoding format for Chinese, and English font is used by default. Therefore, to output Chinese character string, you must transcode Chinese character string and set font used for Chinese characters. Otherwise, the output can only be garbled.
Use the imageTTFText () function to output the text "This is a test" to the image, as follows:
PHP generates Captcha
Create a checks.php file Create a 4-digit Captcha using the GD2 function in the file and save the generated Captcha to the session:
Create a user login form and call checks.php to print the contents of the image in the form:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.