The examples in this article describe the usage of PHP output image imagegif, imagejpeg and imagepng functions. Share it with everyone for your reference, as follows:
imagegif(), imagejpeg(), imagepng() and imagewbmp() functions allow outputting images in GIF, JPEG, PNG and WBMP formats to the browser or document.
PHP Output Image
PHP allows the image to be output in different formats:
imagegif(): Output the image in GIF format to the browser or file
imagejpeg( ): Output the image in JPEG format to a browser or file
imagepng(): Output the image in PNG format to a browser or file
imagewbmp(): Output the image in WBMP format to a browser or file
Syntax:
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 [, int foreground]] )
Parameter description:
Draw an arc and save it Go to the images directory:
<?php header("Content-type: image/png"); $im = @imagecreate(200, 200)or die("创建图像资源失败"); $bg = imagecolorallocate($im, 204, 204, 204); $red = imagecolorallocate($im, 255, 0, 0); imagearc($im, 100, 100, 150, 150, 0, 360, $red); imagepng($im,"images/circle.png"); imagedestroy($im); ?>
A circle.png file will be generated in the images directory.
Hope this article will be helpful to everyone in PHP programming.
For more articles on usage analysis of PHP output image imagegif, imagejpeg and imagepng functions, please pay attention to the PHP Chinese website!