PHP image functions

Source: Internet
Author: User
PHP image function introduction: This is a PHP image Function Details page, describes and 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'> a set of image functions in PHP can dynamically generate gif image data streams 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. copy the H file to the system's Library Directory and header file directory (for example,/usr/lib and/usr/include). if it is in Windows, PHP3.0 will install a gd. dll file, add 'dl ("gd. dll "); 'you can 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, now www. the downloaded file on php.net should have been changed), that is, ImageSetPixel always draws points at (y, y), no matter what the value of x is, but this problem is not very big.

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.