14th Chapter Processing Image _php Tutorial

Source: Internet
Author: User
Learning Essentials:
1. Create an image
2. Simple small case

In PHP5, the processing of dynamic images is much easier than it used to be. PHP5 in the php.ini file contains the GD extension
Package, just remove the appropriate comments for GD expansion pack to work properly. PHP5 contains the GD library is the upgrade
GD2 library, which contains some useful JPG features that support true color image processing.
Generally generated graphics, stored in PHP document format, but can be inserted via HTML image src
To get the dynamic graphics directly. For example, verification code, watermark, thumbnail, and so on.

A Create an image

General process for creating images:
1). Set the header to tell the browser which MIME type you want to generate.
2). Create an image area that will be based on this image area in future operations.
3). Draws the fill background in the blank image area.
4). Draw a graphic outline into the background to enter text.
5). Output the final graphic.
6). Clear all resources.
7). Other pages call the image.

Setting the header specifies the MIME output type

 
  < span="">(' Content-type:image/png '< span="">?>

Create a blank image area

 
  < span="">= Imagecreatetruecolor (200,200< span="">?>

Draw a fill background in a blank image area

 
  < span="">= Imagecolorallocate (< span="">, 0,102,255< span="">< span="">, 0,0,   < span=""> ?>  < span="">

Draw a graphic outline on the background enter text

 
  < span="">= Imagecolorallocate (< span="">, 255,255,255< span="">< span="">, 0,0,200,200 < span="">, < span=""> , 200,0,0,200  ,  < span="">< span=""> < span=""> ?>  < span="">  < span="">  < span="">

Output Final graphic

 
  < span="">< span="">?>

Clear All Resources

 
  < span="">< span="">?>

Graphics created by other page calls

< span="">< span="">< span="">< span="">< span="">< span="">

Two Simple small case

Simple Verification Code

 
  < span="">(' Content-type:image/png '< span="">< span="">(< span="">=0;  < span=""> <4; < span="">++< span="">< span="">.=< span="">(< span="">  < span="">    (0,15< span="">  = Imagecreatetruecolor (75,25  < span="">  < span=""> = imagecolorallocate (< span="">, 0,102,255  < span="">    =< span="">  Imagecolorallocate (< span="">< span="">, 255,255,255< span="">, 0,0,  , 5,20,4 < span="">,,  < span="">  < span="">  < span="">  < span=""> < span="">< span="">< span="">< span="">< span="">? >

Load an existing image

 
  < span="">< span="">< span="">(' content-type:image/png ' (' __dir__ ')< span="">,  ( < span=""> ).' \ \  < span="">    < span="">  ' = Imagecreatefrompng (__dir__. ')  < span="">    222.png '< span="">  = imagecolorallocate (< span="">, 255,255,255  < span="">  , 3,5,5, ' http://www.yc60.com ',  < span="">  < span=""> < span=""> ?>  < span="">  < span="">  < span="">  < span="">

Loading existing system fonts

 
  < span="">< span="">("GBK", "Utf-8", "Li Tinghui"  < span="">    < span="">  = ' C:\WINDOWS\Fonts\SIMHEI. TTF '< span="">< span="">, 20,0,30,30,,< span="">,< span="">  ?> < span="">  < span="">

Miniature image

 (' Content-type:image/png '(' __dir__ ',().' \\'< span="">< span="">(< span="">  , < span=""> )  = < span=""> (__dir__. ')  < span="">   222.png '< span=""> =  * 0.7  < span=""> < span="">    = * 0.7  = Imagecreatetruecolor< span=""> (< span="">   < span=""> < span="">   ,  < span=""> = imagecreatefrompng (__  < span=""> < span=""> < span=""> dir__. ' < span="">222.png '< span="">,  , 0, 0, 0, 0,< span="">, < span=""> < span="">, < span="">, < span="">< span="">< span=""> < span="">< span="">< span="">< span="">< span="">? >

Note: The article is from Eon to PHP video tutorial, this article is limited to exchange use, not for commercial purposes, otherwise the consequences.

http://www.bkjia.com/PHPjc/759625.html www.bkjia.com true http://www.bkjia.com/PHPjc/759625.html techarticle Learning points: 1. Create an image 2. Simple small case in PHP5, the processing of dynamic images is much easier than before. PHP5 in the php.ini file contains the GD expansion pack, just remove the GD extension ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.