Use Imagecreate () to create a variable that represents a blank image, which requires an image-size parameter in pixels, in the format imagecreate (X_size, y_size). If you want to create an image with a size of 250x250, you can use the following statement:
? Header ("Content-type:image/png");
Use Imagecreate () to create a variable that represents a blank image, which requires an image-size parameter in pixels, in the format imagecreate (X_size, y_size). If you want to create an image with a size of 250x250, you can use the following statement:
$newimg = imagecreate (250,250);
Because the image is still blank, you might want to fill it with some color. You need to first use the Imagecolorallocate () function to specify a name for this color with its RGB value, which is formatted as imagecolorallocate ([image], [red], [green], [blue]). If you want to define azure, you can use the following statement:
$skyblue = imagecolorallocate ($newimg, 136,193,255);
Next, you need to fill this image with this color using the Imagefill () function, which has several versions of the Imagefill () function, such as Imagefillrectangle (), Imagefillpolygon (), and so on. For the sake of 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 established, release the image handle and the memory that is occupied:
Imagepng ($NEWIMG);
Imagedestroy ($newimg);? >
In this way, all the code for creating the image looks like this:
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);
? >
http://www.bkjia.com/PHPjc/633012.html www.bkjia.com true http://www.bkjia.com/PHPjc/633012.html techarticle use Imagecreate () to create a variable that represents a blank image, which requires an image-size parameter in pixels, in the format imagecreate (X_size, y_size). If you want to create a ...