Imagick::setImageAlphaChannel


wizard apg

SETS the image alpha channel.



<?php

bool 
public Imagick::setImageAlphaChannel(int $mode);

?>

$mode


The is one of the Imagick::ALPHACHANNEL_* constants.





This function returns a TRUE on success.

This method is available if Imagick has been compiled against ImageMagick version 6.3.8 or newer.



AVAILABLE "imagick" CONSTANTS
STUDIED IN THIS TUTORIAL

1690 - ImageMagick 6.9.10-6
ALPHACHANNEL
CONSTANTVALUEABOUT
imagick::ALPHACHANNEL_ACTIVATE1 ImageMagick version 6.3.8 or higher.
imagick::ALPHACHANNEL_DEACTIVATE4 ImageMagick version 6.3.8 or higher.
imagick::ALPHACHANNEL_RESET 7 ImageMagick version 6.3.8 or higher.
imagick::ALPHACHANNEL_SET8 ImageMagick version 6.3.8 or higher.
imagick::ALPHACHANNEL_UNDEFINED0 ImageMagick version 6.4.6 or higher.
imagick::ALPHACHANNEL_COPY3 ImageMagick version 6.4.6 or higher.
imagick::ALPHACHANNEL_EXTRACT5 ImageMagick version 6.4.6 or higher.
imagick::ALPHACHANNEL_OPAQUE6 ImageMagick version 6.4.6 or higher.
imagick::ALPHACHANNEL_SHAPE9 ImageMagick version 6.4.6 or higher.
imagick::ALPHACHANNEL_TRANSPARENT10 ImageMagick version 6.4.6 or higher.
imagick::ALPHACHANNEL_BACKGROUND2 ImageMagick version 6.5.3 or higher.
imagick::ALPHACHANNEL_REMOVE 12 ImageMagick version 6.7.8 or higher.
imagick::ALPHACHANNEL_ASSOCIATE 13 ImageMagick version 6.9.0 or higher.
imagick::ALPHACHANNEL_DISSOCIATE 14 ImageMagick version 6.9.0 or higher.
imagick::ALPHACHANNEL_ON ImageMagick version 7.0.0 or higher.
imagick::ALPHACHANNEL_OFF ImageMagick version 7.0.0 or higher.
imagick::ALPHACHANNEL_DISCRETE ImageMagick version 7.0.0 or higher.
ed48

  1 EXERCISE   

<?php

    $str1img 
PATH2IMGW '/results/9new sa.png';
    
$str1iimg 'img/results/9new sa.png';
    

    
$imagick = new Imagick();    

    
$imagick->newPseudoImage(200100"gradient:red-rgba(25, 255, 0, 0.5)");
    
$imagick->setImageFormat('png');
    
$imagick->setImageAlphaChannel(Imagick::ALPHACHANNEL_COPY);
    
    
$data $imagick->getImageBlob();

    
$im imagecreatefromstring($data);
    
    
imagepng($im$str1img);

?>


<img src="<?php echo $str1iimg?>"
 alt="<?php echo $str1iimg?>
 title="<?php echo $str1iimg?>">

 RESULT   

img/results/9new sa.png apr

  2 EXERCISE   

<?php

// Run several times

    
$str1img PATH2IMGW '/results/9new sa2.png';
    
$str1iimg 'img/results/9new sa2.png';

    
$imagick = new Imagick();    

    
$imagick->newPseudoImage(200100"gradient:red-rgba(25, 255, 0, 0.5)");
    
$imagick->setImageFormat('png');
    
    
$imagick->setImageAlphaChannel(Imagick::ALPHACHANNEL_COPY);
    
    
$data $imagick->getImageBlob();

    
$im imagecreatefromstring($data);
    
    
imagepng($im$str1img);

?>

<img src="<?php echo $str1iimg?>"
 alt="<?php echo $str1iimg?>
 title="<?php echo $str1iimg?>">