PHP image Functions

Source: Internet
Author: User

Introduction: This is a detailed page of PHP image functions. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 326920 'rolling = 'no'>

PHP has a set of image functions that can dynamically generate image data streams in GIF format and output them to the server. for this set of functions to work, the GD library must be supported in the system. in UNIX, the source code of GD should be obtained and compiled before PHP is compiled to generate libgd. A and some. h file, respectively copied to the system's library directory and header file directory (for example,/usr/lib and/usr/include); if it is in windows, php3.0 InstallationProgramWill install a GD. dll file, add 'dl ("GD. dll"); 'in the program to use the image function.

Main image functions include:

(1) imagecreate (width, height)

Returns an image descriptor.

(2) imagecreatefromgif (File Name );

Returns an image descriptor.

(3) imagecolorallocate (Image Descriptor, red, green, blue );

Returns a color descriptor. Since a GIF image can only have 256 colors, you must first assign a color palette to it. This statement is to assign a color palette item.

(4) imagecolortransparent (Image Descriptor, color descriptor );

Specify a transparent color.

(5) imagearc (Image Descriptor, center X coordinate, center y coordinate, elliptical width, elliptical height, starting angle, ending angle, color descriptor );

Imagechar (Image Descriptor, Font, X, Y, character, color descriptor );

Imagecharup (Image Descriptor, Font, X, Y, character, color descriptor );

Imagecopyresized (Target Image Descriptor, source Image Descriptor, target X, target y, source X, source y, target width, target height, Source width, and source height );

Imagedashedline (Image Descriptor, X1, Y1, X2, Y2, color descriptor );

Imagefill (Image Descriptor, starting point X, starting point y, color descriptor );

Imagefilledpolygon (Image Descriptor, each vertex array, number of vertices, color descriptor );

Imagefilledrectangle (Image Descriptor, X1, Y1, X2, Y2, color descriptor );

Imagefilltoborder (Image Descriptor, starting point X, starting point y, boundary color, fill color );

Imageline (Image Descriptor, X1, Y1, X2, Y2, color descriptor );

Imagepolygon (Image Descriptor, each vertex array, number of vertices, color descriptor );

Imagerectangle (Image Descriptor, X1, Y1, X2, Y2, color descriptor );

Imagesetpixel (Image Descriptor, X, Y, color descriptor );

Imagestring (Image Descriptor, Font, X, Y, String, color descriptor );

Imagestringup (Image Descriptor, Font, X, Y, String, color descriptor );

All of these are drawing functions. What needs to be explained is that the vertex array of the polygon stores the first vertex x, the first vertex y, the second vertex x, the second vertex y ,...

(6) imageloadfont (File Name );

The file should be a bitmap font file and return a font number. The system defaults to 1-5 font numbers, which can be used directly.

(7) imagesx, imagesy

Obtain the width and height of an image and receive an Image Descriptor parameter.

(8) imagecolorat (Image Descriptor, x, y );

Imagecolorclosest (Image Descriptor, red, green, blue );

Imagecolorexact (Image Descriptor, red, green, blue );

Imagecolorset (Image Descriptor, color descriptor, red, green, blue );

Imagecolorsforindex (Image Descriptor, color descriptor );

Imagecolorstotal (Image Descriptor );

The first three return a color descriptor. imagecolorexact. If no matching is found,-1 is returned.

Imagecolorsforindex returns an array of three elements: Red, green, and blue.

Imagecolorstotal returns the total number of colors.

(9) imagefontheight, imagefontwidth

Receives a font number as a parameter.

(10) imagegif (Image Descriptor, [file name]);

If there is no file name, The GIF data stream is sent to the browser. At this time, the program should start with a sentence: Header ("Content-Type: image/GIF ")

(11) imagedestroy (Image Descriptor );

There is a small bug in the image function (at least in the source code of php3.0rc and php3.0rc3 for UNIX, and now the download file on www.php.net should have been changed), that is, imagesetpixel is always in (Y, Y) no matter what the value of X is, this is not a big problem.

More articles on "php image functions"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/326920.html pageno: 13.

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.