The example of this article describes the PHP output image imagegif, imagejpeg and imagepng function usage. Share to everyone for your reference, specific as follows:
The Imagegif (), imagejpeg (), Imagepng (), and imagewbmp () functions allow images to be exported to browsers or files in GIF, JPEG, PNG, and WBMP formats, respectively.
PHP Output Image
PHP allows images to be exported in different formats:
Imagegif (): Prints an image to a browser or file in GIF format
imagejpeg (): Output the image to a browser or file in JPEG format
Imagepng (): Output the image to a browser or file in PNG format
Imagewbmp (): Output an image to a browser or file in WBMP format
Grammar:
BOOL Imagegif (resource image [, string filename])
bool Imagejpeg (resource image [, string filename [, int quality ])
bool Imagepng (resource image [, string filename])
bool Imagewbmp (resource image [, string filename [, in T foreground]])
Parameter description:
Parameters |
Description |
Image |
The return value of an image resource, such as a imagecreate () or Imagecreatefrom series function, that you want to output |
FileName |
Optionally, specify the file name of the output image. If omitted, the original image stream is directly exported. |
Quality |
Optional, specify image quality, range from 0 (worst quality, file minimum) to 100 (best quality, File max), default, imagejpeg () unique parameter |
Foreground |
Optionally, specify the foreground color, the default foreground color is black, imagewbmp () unique parameter |
Draw an arc and save it to the images directory:
<?php
Header ("Content-type:image/png");
$im = @imagecreate or Die ("Create Image resource Failed");
$BG = Imagecolorallocate ($im, 204, 204, 204);
$red = Imagecolorallocate ($im, 255, 0, 0);
Imagearc ($im, 0, 360, $red);
Imagepng ($im, "images/circle.png");
Imagedestroy ($im);
? >
A circle.png file is generated in the images directory.
More about PHP Interested readers can view the site topics: "PHP graphics and pictures Operating skills summary", "PHP file Operation Summary", "PHP Array" operation Skills Encyclopedia, "PHP Basic Grammar Introductory Course", "PHP Operations and Operator Usage Summary", " Introduction to PHP object-oriented programming program, "PHP Network Programming Skills Summary", "PHP string (String) Usage Summary", "Php+mysql database Operation Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design.