The main use of the GD library two methods:
Copy CodeThe code is as follows:
Imagecolorallocatealpha//Assign color + Alpha
Imagesavealpha//Set to save full alpha channel information when saving PNG images
code example:
Copy the Code code as follows:
Get source map GD image identifier
$SRCIMG = Imagecreatefrompng ('./src.png ');
$srcWidth = Imagesx ($SRCIMG);
$srcHeight = Imagesy ($SRCIMG);
Create a new diagram
$newWidth = Round ($srcWidth/2);
$newHeight = Round ($srcHeight/2);
$NEWIMG = Imagecreatetruecolor ($newWidth, $newHeight);
Assign color + Alpha to fill the new diagram with color
$alpha = Imagecolorallocatealpha ($newImg, 0, 0, 0, 127);
Imagefill ($newImg, 0, 0, $alpha);
Copy the source map to the new diagram and set the full alpha channel information to be saved when the PNG image is saved
Imagecopyresampled ($NEWIMG, $srcImg, 0, 0, 0, 0, $newWidth, $newHeight, $srcWidth, $srcHeight);
Imagesavealpha ($NEWIMG, true);
Imagepng ($NEWIMG, './dst.png ');
http://www.bkjia.com/PHPjc/621653.html www.bkjia.com true http://www.bkjia.com/PHPjc/621653.html techarticle The main use of the GD library two methods: Copy code code as follows: Imagecolorallocatealpha//Assign color + Alpha Imagesavealpha//set to save full alpha when saving PNG image ...