Easy Tutorial
❮ Func Array Pad Php Eof Heredoc ❯

PHP imagealphablending - Set Image Blending Mode

PHP Image Processing

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

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);
?>

PHP Image Processing

❮ Func Array Pad Php Eof Heredoc ❯