Php image creation steps, php image steps
Php image processing is the most common in the verification code. The following describes how to create an image using php.
Brief description:PHP is not limited to creating HTML output. It can also be created and processed, includingGIF, PNG (recommended), JPEG, WBMP, and XPMImages in multiple formats. More conveniently, PHP can directly output the image data stream to the browser. To use the image processing function in PHP, You need to compile PHP together with the GD library. The GD library and PHP may need other libraries, depending on the image format you want to process.
You can use the image function in PHP to obtain images in the following format:JPEG, GIF, and PNG (recommended: Images Created with no pins left), SWF, TIFF, and MPEG-4.
Step Description: For details about the function, refer to the php manual.
<? Php // first: Set the header to tell the browser the MIME type header ("Content-type: image/png") You want to generate; // Second: Create a canvas, subsequent operations will be based on the canvas area $ codew = 100; $ codeh = 60; $ codeimg = imagecreatetruecolor ($ codew, $ codeh ); // obtain the canvas color $ red = imagecolorallocate ($ codeimg, 255, 0, 0); $ white = imagecolorallocate ($ codeimg, 255,255,255); $ green = imagecolorallocate ($ codeimg, 75,222, 26); // third: Fill the canvas background color imagefill ($ codeimg, 0, 0, $ red); // Fourth: draw lines + fill text... imageline ($ cod Eimg, 0, 00, 30, 60, $ white); imageline ($ codeimg, 0, 00, 50, 60, $ white); imageline ($ codeimg, 0, 00, 80, 60, $ white); // fill in the text imagestring ($ codeimg, 10, 30, 30, "qwe4", $ green); // Fifth: output The created canvas imagepng ($ codeimg); // Sixth: destroy the canvas imagedestroy ($ codeimg);?>
View results
The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!