Usage analysis of PHP output image imagegif, imagejpeg and imagepng functions

高洛峰
Release: 2023-03-04 09:26:02
Original
3530 people have browsed it

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]] )
Copy after login

Parameter description:

Usage analysis of PHP output image imagegif, imagejpeg and imagepng functions

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);
?>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!