Php tutorial image 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 formats supported by the gd library associated with the current php version in the form of bits. The following result is returned: img_gif | img_jpg | img_png | img_wbmp | img_xpm. For example, to check whether png is supported
*/
// Create an image
$ Img = imagecreatetruecolor (0, 300,200 );
// Obtain the Image Width
Echo imagesx ($ img );
/*
View instances
*/
// Create an image of 100x30
$ Im = imagecreate (100,30 );
// White background and blue text
$ Bg = imagecolorallocate ($ im, 255,255,255 );
$ Textcolor = imagecolorallocate ($ im, 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 *, the background is completely transparent, and all actions are taken for reference, perform the following operations:
*/
$ 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 e ($ png, 400,300,400,300, $ red );
Header ("content-type: image/png ");
Imagepng ($ png );