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