Fun image function library-Common graphic operations

Source: Internet
Author: User
Tags image identifier

I try not to talk about big theory, for example, what is png.

PHP has bound its own GD2 Library since version 4.3. You can download and set it yourself. to check whether your php version supports the gd module (supports JPEG, PNG, WBMP, but does not support GIF), use the following method:

If (! Function_exists ('imagecreate ')){
Die ('the current server does not support GD module ');
}

If not, how can I configure it? Download the dll file of the gd module, modify php. ini, and restart the server.

The PHP plot is PS.

When you plan to PS, you should complete the following steps, which is necessary.

1: Create a basic PS object (I suppose it is $ image) and fill in the background (black by default). All subsequent ps operations will be based on this background image.
2: plot on $ image.
3: output this image.
4. Destroy objects and clear memory usage.

First, let's get to know several common functions. These functions are described in detail in the php manual.

Resource imagecreate (int x_size, int y_size)
Imagecreate () returns an image identifier, representing a blank image of x_size and y_size.
This function is basically the same as imagetruecolor ($ width, $ height ).

Int imagecolorallocate (resource image, int red, int green, int blue)
Imagecolorallocate () returns an identifier representing a color consisting of a given RGB component. The image parameter is the return value of the imagecreatetruecolor () function. Red, green, and blue are the required colors respectively. These parameters are integers from 0 to 255 or hexadecimal values 0x00 to 0xFF. Imagecolorallocate () must be called to create the color of each image used in the image.

Bool imagefill (resource image, int x, int y, int color)
Imagefill () is filled with the color execution area (that is, with x, y points are in the same color and adjacent points are filled ).


Bool imageline (resource image, int x1, int y1, int x2, int y2, int color)
Imageline () uses color to draw a line segment from the coordinates x1, y1 to x2, y2 (0 in the upper left corner of the image.

Bool imagestring (resource image, int font, int x, int y, string s, int col)
Imagestring () uses the col color to draw string s to the x and y coordinates of the image (this is the coordinate of the upper left corner of the string, and the upper left corner of the entire image is 0, 0 ). If the font is 1, 2, 3, 4, or 5, the built-in font is used.

Array imagettftext (resource image, float size, float angle, int x, int y, int color, string fontfile, string text)
This function is important and has many parameters. It is not listed here. It is mainly written to an image. It is similar to the above function, but must be powerful.

Bool imagefilltoborder (resource image, int x, int y, int border, int color)
Imagefilltoborder () starts from x, y (0, 0 in the upper left corner of the image) and fills the area with color until the border of the color is border is reached. [Note: All colors in the boundary are filled. If the specified boundary color is the same as that of the vertex, It is not filled. If this boundary color does not exist in the image, the entire image will be filled .]

Bool imagefilledellipse (resource image, int cx, int cy, int w, int h, int color)
Imagefilledellipse () draws an elliptical image centered on cx and cy (0, 0 in the upper left corner of the image. W and h specify the width and height of the elliptic respectively. Fill the ellipse with color. If the call succeeds, TRUE is returned. If the call fails, FALSE is returned.

Output image data: imagepng ($ image [, $ filename])

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.