PHP graphics processing function imagetype_PHP tutorial

WBOY
Release: 2016-07-13 16:58:59
Original
1249 people have browsed it

php tutorial graphics processing function imagetypes() imagecreatetruecolor() imagecreate()
//Determine whether the current gd library supports png

if(imagetypes() & img_png)
{
echo "png support is enabled";
}
else
{
echo "png support is disabled";
}
/*
int imagetypes (void)


This function returns the image format supported by the gd library associated with the current PHP version in the form of a bit field. The following results will be returned, img_gif | img_jpg | img_png | img_wbmp | img_xpm. For example to check if png

is supported

*/

//Create image
$img=imagecreatetruecolor(300,200);
//Get image width
echo imagesx($img);


/*
Let’s see an example
*/

//Create a 100x30 image
$im=imagecreate(100,30);
//White background and blue text
$bg=imagecolorallocate($im,255,255,255);
$textcolor=imagecolorallocate($im,0,0,255);
//Write the string in the upper left corner of the image
imagestring($im,5,0,0,"hello world!",$textcolor);
//Output image
header("content-type: image/png");
imagepng($im);


/*
If you want to create a png image *transparent* where the background is completely transparent and all the action happens within the draw, other than that, then do the following:
*/

$png = imagecreatetruecolor(800, 600);
imagesavealpha($png, true);
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
Imagefill($png, 0, 0, $trans_colour);
 
$red = imagecolorallocate($png, 255, 0, 0);
Imagefilledellips tutorial tutorial e($png, 400, 300, 400, 300, $red);
 
header("content-type: image/png");
Imagepng($png);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631351.htmlTechArticlephp tutorial graphics processing function imagetypes() imagecreatetruecolor() imagecreate() //Determine whether the current gd library supports png if(imagetypes() img_png) { echo png support is enabled; } else {...
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!