PHP Graphics processing Tutorial-php generating Picture (_php) tutorial

Source: Internet
Author: User
In the Web application is often used to generate pictures this function, in PHP tutorial to create a picture needs GD library support to create graphics, with this graphical function, we can easily generate thumbnails, verification code, image watermark and so on.

In PHP to install the GD library in order to run the Create image function, as follows, in the win system, find php.ini

Extension=php_gd2.dll in front of the ";" Go, re-start Apache is OK.

Now let's look at an example

PHP's GD library can generate a variety of image files, such as GIF,PNG,JPG,WBMP,XPM, and then look at a square-generated file.

$height = 300;
$width = 300;
Create a background map
$im = Imagecreatetruecolor ($width, $height);
assigning colors
$white = Imagecolorallocate ($im, 255, 255, 255);
$blue = imagecolorallocate ($im, 0, 0, 64);
Draw Color to Image
Imagefill ($im, 0, 0, $blue);
Draw string: hello,php
Imagestring ($im, ten, +, +, ' hello,php ', $white);
Output image, define Header
Header (' content-type:image/png ');
Send an image to a browser
Imagepng ($im);
Clear Resources
Imagedestroy ($im);
?>

View results as long as you browse the PHP file, if you want the image to call

Example two, creating a picture using basic functions Imagecreate ()

resource imagescreate (int x,inty)

Imagedestroy is the amount of memory space that the picture occupies

int Ingaedestroy (image)

Imagecopy ()

int imagecopy (dst_im,sr_im,int x,int y,int x,int y,)

1 2 3 4

http://www.bkjia.com/PHPjc/633047.html www.bkjia.com true http://www.bkjia.com/PHPjc/633047.html techarticle in the Web application is often used to generate pictures this feature, in PHP tutorial to create a picture needs GD library support to create graphics, with this graphical function, we can easily generate ...

  • 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.