PHP output Image imagegif, imagejpeg and Imagepng functions

Source: Internet
Author: User
Tags imagejpeg

The Imagegif (), imagejpeg (), Imagepng (), and imagewbmp () functions allow images to be exported to a browser or file in GIF, JPEG, PNG, and WBMP formats, respectively.

PHP Output Image

PHP allows images to be exported in different formats:

    • Imagegif (): Output images to a browser or file in GIF format
    • imagejpeg (): Output images to a browser or file in JPEG format
    • Imagepng (): Output images 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]]) b Ool Imagepng (Resource image [, string filename]) bool Imagewbmp (resource image [, string filename [, int foreground]] )
Parameter description:
Parameters Description
Image The return value of the image resource to be exported, such as imagecreate () or Imagecreatefrom series functions
FileName Optionally, specify the file name of the output image. If omitted, the original image stream will be output directly.
Quality Optional, specify image quality, range from 0 (worst quality, file minimum) to 100 (best quality, File max), default imagejpeg () unique parameter
Foreground Optional, specify foreground color, default foreground color is black, imagewbmp () unique parameter

Draw an arc and save it to the images directory:

<?phpheader ("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, N, 0,, $red); Imagepng ($im, "I Mages/circle.png "); Imagedestroy ($im);? >

A circle.png file is generated in the images directory.

PHP output Image imagegif, imagejpeg and Imagepng functions

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.