<?php
bool imagelayereffect ( GdImage $image, int $effect )
where,
$image = The image identifier
$effect = The effect to be used
( SEE the below TABLE )
?>
IMAGE LAYER EFFECT CONSTANTS | ||
CONSTANT | VALUE | MEANING |
IMG_EFFECT_REPLACE | 0 | Use pixel replacement. Equivalent of passing TRUE to imagealphablending. |
IMG_EFFECT_ALPHABLEND | 1 | Use pixel replacement. Equivalent of passing FALSE to imagealphablending. |
IMG_EFFECT_NORMAL | 2 | Same as IMG_EFFECT_ALPHABLEND. |
IMG_EFFECT_OVERLAY | 3 | Overlay has the effect that black background pixels will remain black, white background pixels will remain white, but grey background pixels will take the colour of the foreground pixel. |
IMG_EFFECT_MULTIPLY | 4 | Overlays with a multiply effect. |
ed48 |
<?php
// RUN this code several times
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$lang = 'en';
$org_img = "jpeg/JPEG 031 01.jpg";
$msk_img = "png/PNG 070 01 mask.png";
$dst_img = "png/PNG 070 01 imagelayereffect.png";
$en = '<br><br>EXISTING IMAGE';
$id_orgimg = imagecreatefromjpeg($org_img);
echo $org_img; ?><?php echo $$lang; ?><br><br>
<img src="<?php echo $org_img; ?>"
alt="<?php echo $org_img; ?>"
title="<?php echo $org_img; ?>"><br><br><br>
<?php
$en = '<br><br>MASK IMAGE';
$id_mskimg = imagecreatetruecolor (400, 400);
$rnred = mt_rand(0 , 255);
$rngreen = mt_rand(0 , 255);
$rnblue = mt_rand(0 , 255);
$alphfac = mt_rand(0, 127);
$alpha_color = imagecolorallocatealpha($id_mskimg,
$rnred,
$rngreen,
$rnblue,
$alphfac);
imagefill($id_mskimg, 0, 0, $alpha_color);
imagepng($id_mskimg, $msk_img);
echo $msk_img; ?><?php echo $$lang; ?><br>
<?php echo 'RGB = ( ' . $rnred . ', ' . $rngreen . ', ' .
$rnblue . ' )<br><br>'; ?>
<img src="<?php echo $msk_img; ?>"
alt="<?php echo $msk_img; ?>"
title="<?php echo $msk_img; ?>"><br><br>
<?php
$effect01 = [ IMG_EFFECT_REPLACE, IMG_EFFECT_ALPHABLEND,
IMG_EFFECT_NORMAL, IMG_EFFECT_OVERLAY,
IMG_EFFECT_MULTIPLY ];
$effect02 = [ "IMG_EFFECT_REPLACE", "IMG_EFFECT_ALPHABLEND",
"IMG_EFFECT_NORMAL", "IMG_EFFECT_OVERLAY",
"IMG_EFFECT_MULTIPLY" ];
$eff01 = mt_rand(0, 4);
$effname = $effect02[$eff01];
imagelayereffect($id_mskimg, $eff01);
imagecopy($id_orgimg, $id_mskimg, 200, 0, 0, 0, 400, 400);
imagepng($id_orgimg, $dst_img);
$md2_type = $effname . '<br>ALPHA = ' . $alphfac;
echo $dst_img .'<br><br>' . $md2_type; ?><br><br>
<img src="<?php echo $dst_img; ?>"
alt="<?php echo $dst_img; ?>"
title="<?php echo $dst_img; ?>"><br>
<?php
// RUN this code several times
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$lang = 'en';
$org_img = "jpeg/JPEG 031 01.jpg";
$msk_img = "png/PNG 070 02 mask.png";
$dst_img = "png/PNG 070 02 imagelayereffect.png";
$en = '<br><br>EXISTING IMAGE';
$id_orgimg = imagecreatefromjpeg($org_img);
echo $org_img; ?><?php echo $$lang; ?><br><br>
<img src="<?php echo $org_img; ?>"
alt="<?php echo $org_img; ?>"
title="<?php echo $org_img; ?>"><br><br><br>
<?php
$en = '<br>MASK IMAGE';
$id_mskimg = imagecreatetruecolor (400, 400);
$rnred = mt_rand(0 , 255);
$rngreen = mt_rand(0 , 255);
$rnblue = mt_rand(0 , 255);
$alphfac = mt_rand(0, 127);
$alpha_color = imagecolorallocatealpha($id_mskimg,
$rnred,
$rngreen,
$rnblue,
$alphfac);
imagefill($id_mskimg, 0, 0, $alpha_color);
imagepng($id_mskimg, $msk_img);
echo $msk_img; ?><?php echo $$lang; ?><br>
<?php echo 'RGB = ( ' . $rnred . ', ' . $rngreen . ', ' .
$rnblue . ' )<br><br>'; ?>
<img src="<?php echo $msk_img; ?>"
alt="<?php echo $msk_img; ?>"
title="<?php echo $msk_img; ?>"><br><br>
<?php
$effect01 = [ IMG_EFFECT_REPLACE, IMG_EFFECT_ALPHABLEND,
IMG_EFFECT_NORMAL, IMG_EFFECT_OVERLAY,
IMG_EFFECT_MULTIPLY ];
$effect02 = [ "IMG_EFFECT_REPLACE", "IMG_EFFECT_ALPHABLEND",
"IMG_EFFECT_NORMAL", "IMG_EFFECT_OVERLAY",
"IMG_EFFECT_MULTIPLY" ];
$eff01 = mt_rand(0, 4);
$effname = $effect02[$eff01];
imagelayereffect($id_mskimg, $eff01);
imagecopy($id_orgimg, $id_mskimg, 0, 0, 0, 0, 400, 400);
imagepng($id_orgimg, $dst_img);
$md2_type = '<br>' . $effname . '<br>ALPHA = ' . $alphfac;
echo $dst_img; ?> <?php echo $md2_type; ?><br><br>
<img src="<?php echo $dst_img; ?>"
alt="<?php echo $dst_img; ?>"
title="<?php echo $dst_img; ?>"><br><br>