Php creates an image instance. Use ImageCreate () to create a variable that represents a blank image. this function requires a parameter of the image size in pixels. the format is ImageCreate (x_size, y_size ). If you want to create a variable that represents a blank image using ImageCreate (), this function requires an image size parameter in pixels. the format is ImageCreate (x_size, y_size ). To create an image of 250x250 in size, use the following statement:
<? Header ("content-type: image/png ");
Use imagecreate () to create a variable that represents a blank image. this function requires a parameter of the image size in pixels. the format is imagecreate (x_size, y_size ). To create an image of 250x250 in size, use the following statement:
$ Newimg = imagecreate (250,250 );
Because the image is still blank, you may want to fill it with some color. You must first use the imagecolorallocate () function to specify a name for this color with its rgb value. The format of this function is imagecolorallocate ([image], [red], [green], [blue]). To define the sky blue, use the following statement:
$ Skyblue = imagecolorallocate ($ newimg, 136,193,255 );
Next, you need to use the imagefill () function to fill the image with this color. the imagefill () function has several versions, such as imagefillrectangle () and imagefillpolygon. For simplicity, we use the imagefill () function in the following format:
Imagefill ([image], [start x point], [start y point], [color])
Imagefill ($ newimg, 0, 0, $ skyblue );
Finally, after the image is created, the image handle and occupied memory are released:
Imagepng ($ newimg );
Imagedestroy ($ newimg);?>
The code for creating an image is as follows:
Php Tutorial code:
<? Header ("content-type: image/png ");
$ Newimg = imagecreate (250,250 );
$ Skyblue = imagecolorallocate ($ newimg, 136,193,255 );
Imagefill ($ newimg, 0, 0, $ skyblue );
Imagepng ($ newimg );
Imagedestroy ($ newimg );
?>
Fill () creates a variable that represents the blank image. this function requires the parameter of the image size in pixels, in the format of ImageCreate (x_size, y_size ). If you want to create...