Dynamic image processing-php (34), Dynamic image processing php34_php tutorial

Source: Internet
Author: User

Dynamic image processing-php (34), Dynamic image processing Php34


1 use of the GD library in PHP

PHP is not limited to producing only HTML output, but it can also create and manipulate image files in many different formats. PHP provides some built-in image information functions, or you can use the GD library to create new images or work with existing images. Currently, the GD2 Library supports JPEG, PNG, and wbmp formats. GIF format is no longer supported.

JPEG is the name of a compression standard, usually used to store photos or to store images with rich color and color levels. This format uses lossy compression.

PNG is a portable network image that uses lossless compression standards for images.

wbmp is a file format designed specifically for wireless communication devices. But it has not been widely used.

2 Steps for image generation

Creating an image in PHP should complete the 4 steps shown below:
1. Create a background image (also called the canvas), and the subsequent operations are based on this background image.
2. Draw the outline of the image or enter text on the background.
3. Output Final Graphics
4. Releasing Resources

 !--? 
   
     php 
    //  Create background image  $height =  $  ; $width  =   ; $im  = Imagecreatetruecolor ($width, $height); //  Create a blank background  $white = Imagecolorallocate ($im,  255 ,  255 ,  255 ); //  Set Drawing color  $blue = imagecolorallocate ($im,  0 ,  0 ,   ); Imagefill ($im,   0 ,  0 , $blue); //  Draw Background  imageline ($im,  0 ,  0 , $width, $height, $white); //  Draw line  imagestring ($im,  4 ,  ,  all ,  '   Sales   ' , $white); //  Add string  header ( '   content-type:image/png   '  ); Imagepng ($im);  //  Export the image in PNG format   Imagedestroy ($im); ? 

3 Canvas Management

imagecreate--Creating a new palette-based image

http://www.bkjia.com/PHPjc/1007363.html www.bkjia.com true http://www.bkjia.com/PHPjc/1007363.html techarticle Dynamic image processing-php (34), dynamic image processing Php34 1 in PHP the use of the GD library PHP is not limited to producing only HTML output, but also can create and manipulate many different formats of image files ...

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