Description: This function is used to create a GIF format graphics, parameters im for the use of Imagecreate () created by the image code, parameter filename can be omitted, if there is no this parameter filename, the image will be sent to the browser side, remember to send out the image before the use of Content-type:image/gif the header string (header) to the browser side to smooth the transfer of the picture. To use a transparent background gif, which is the gif89a format, you need to first configure the transparent background with imagecolortransparent ().
$values =array (
40,50,//coordinates of the first vertex
20,240,//coordinates of the first vertex
60,60,//coordinates of the first vertex
240,20,//coordinates of the first vertex
50,40,//coordinates of the first vertex
10,10//coordinates of the first vertex
);
$im =imagecreatetruecolor (250,250); Create an image
$BG =imagecolorallocate ($im, 200,200,200); Define a gray background
$yellow =imagecolorallocate ($im, 255,255,0); Define yellow foreground
Imagefilledpolygon ($im, $values, 6, $yellow); Draw a polygon
Header (' content-type:image/png ');
Determine if GIF function exists
if (function_exists ("Imagegif"))
{
If present, output in GIF format
Header ("Content-type:image/gif");
Imagegif ($im);
}
Determine if the JPEG function exists
ElseIf (function_exists ("imagejpeg"))
{
If present, output in JPG format
Header ("Content-type:image/jpeg");
Imagejpeg ($im, "", 0.5);
}
Determine if the PNG function exists
ElseIf (function_exists ("Imagepng"))
{
If present, output in PNG format
Header ("Content-type:image/png");
Imagepng ($im);
}
Determine if the Wbmp function exists
ElseIf (function_exists ("Imagewbmp"))
{//Open source code phpfensi.com
If present, output in BMP format
Header ("Content-type:image/vnd.wap.wbmp");
/*
The header () function sends the original HTTP header to the client, recognizing that it is important to call the header () function before any actual output is sent (in PHP 4 and later, you can use output caching to resolve this issue):
*/
Imagewbmp ($im);
}
Else
{
If neither is supported, the output content
Die ("No image, support in this PHP server");
}
/*
The code executes the same result as code 22-25, which, unlike the code, judges multiple image support and then prints the image in the appropriate format.
Syntax: int imagegif (int im, string [filename]);
Return value: Integer, Function type: graphics processing