Dynamic Image Processing-php (34) and dynamic image processing php34

Source: Internet
Author: User

Dynamic Image Processing-php (34) and dynamic image processing php34
1 Use of GD library in PHP

PHP can not only generate HTML output, but also create and operate image files of different formats. PHP provides some built-in image information functions. You can also use the GD function library to create new images or process existing images. Currently, the GD2 Library supports JPEG, PNG, and WBMP formats. However, the GIF format is no longer supported.

• JPEG is a standard name for compression. It is usually used to store photos or images with rich colors and color layers. This format uses lossy compression.

• PNG is a portable network image that adopts lossless compression standards.

• WBMP is a file format specially designed for wireless communication devices. But it is not widely used.

2. Image Generation steps

To create an image in PHP, follow these steps:
1. Create a background image (also called a canvas). Subsequent operations are based on this background image.
2. Draw an image profile or input text on the background.
3. Output final image
4. release resources

<? Php // create a background image $ height = 200; $ width = 200; $ im = ImageCreateTrueColor ($ width, $ height ); // create a blank background $ white = ImageColorAllocate ($ im, 255,255,255); // set the drawing color $ blue = ImageColorAllocate ($ im, 0, 0, 64 ); imageFill ($ im, 0, 0, $ blue); // draw the background imageLine ($ im, 0, 0, $ width, $ height, $ white ); // draw the line imageString ($ im, 4, 50,150, 'sales', $ white); // Add the string header ('content-type: image/png '); imagePng ($ im); // output the image to imageDes in PNG format Troy ($ im);?>
3. Canvas Management

Imagecreate-create a palette-Based Image

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.