PHP imagealphablending - Set Image Blending Mode
imagealphablending — Set the blending mode for an image.
Syntax
bool imagealphablending ( resource $image , bool $blendmode )
imagealphablending() allows two different modes for drawing on truecolor images.
In blending mode, the alpha channel component is provided to all drawing functions, such as imagesetpixel(), which determines how much the underlying color should be allowed to show through. As a result, GD automatically blends the existing color at the point with the drawing color, and stores the result in the image. The resulting pixel is opaque.
In non-blending mode, the drawing color is copied along with its alpha channel information, replacing the destination pixel. Blending mode is not available when drawing on palette images.
If blendmode is TRUE, blending mode is enabled; otherwise, it is disabled. Returns TRUE on success or FALSE on failure.
Parameters
image A image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
blendmode Whether to enable blending mode. TRUE by default for truecolor images, otherwise FALSE.
Return Values
Returns TRUE on success or FALSE on failure.
Example
<?php
// Create an image
$im = imagecreatetruecolor(100, 100);
// Enable blending mode
imagealphablending($im, true);
// Draw a square
imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));
// Output
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>