PHP function_exists judgment function available code

Source: Internet
Author: User
Tags imagejpeg php server
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

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