PHP | Imagick setImageAlphaChannel() Function
Last Updated :
15 Nov, 2019
The Imagick::setImageAlphaChannel() function is an inbuilt function in PHP which is used to set the image alpha channel.
Syntax:
bool Imagick::setImageAlphaChannel( int $mode )
Parameters: This function accepts single parameter $mode which holds an integer value corresponding to one of the ALPHACHANNEL constants.
List of ALPHACHANNEL constants are given below:
- imagick::ALPHACHANNEL_ACTIVATE (0)
- imagick::ALPHACHANNEL_DEACTIVATE (1)
- imagick::ALPHACHANNEL_RESET (2)
- imagick::ALPHACHANNEL_SET (3)
- imagick::ALPHACHANNEL_UNDEFINED (4)
- imagick::ALPHACHANNEL_COPY (5)
- imagick::ALPHACHANNEL_EXTRACT (6)
- imagick::ALPHACHANNEL_OPAQUE (7)
- imagick::ALPHACHANNEL_SHAPE (8)
- imagick::ALPHACHANNEL_TRANSPARENT (9)
Return Value: This function returns TRUE on success.
Below programs illustrate the Imagick::setImageAlphaChannel() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$imagick ->setImageBackgroundColor( 'blue' );
$imagick ->setImageAlphaChannel(9);
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick(
$imagick ->setImageAlphaChannel(3);
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.setimagealphachannel.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...