You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add this code to: ImageWorkshopLayer.php
too allow you to apply layer mask.
to use $layer_you_wish_to_apply_mask->applyalphamask($mask_layer);
/**
* Apply alpha layer mask.
* can be slower so best for images you don't need to remake for every user.
* @param layer $mask
*
* @author email [email protected]
*
*/
public function applyalphamask($mask){
$layerWidth = $this->width;
$layerHeight = $this->height;
$masktemp = clone $mask;
$masktemp->resizeInPixel($layerWidth, $layerHeight); // make $mask and $layer the same size.
$masktemp->applyFilter(IMG_FILTER_GRAYSCALE); //converts to greyscale if not greyscale;
$masktemp->applyFilter(IMG_FILTER_NEGATE);
$layerImg= $this->getImage();
$maskImg = $masktemp->getImage();
$imgtemp = imageCreateTrueColor($layerWidth,$layerHeight);
imagealphablending($imgtemp, false);
imagesavealpha($imgtemp, true);
for ($h=0; $h<$layerHeight; $h++){
for ($w=0; $w<$layerWidth; $w++){
$Lrgb = imagecolorat($layerImg, $w, $h);
$Lcolors = imagecolorsforindex($layerImg, $Lrgb);
$Mrgb = imagecolorat($maskImg, $w, $h);
$Mcolors = imagecolorsforindex($maskImg, $Mrgb);
$alpha = $Mcolors["red"]/255*127;
//$alpha = (int)( $alpha);
imagesetpixel($imgtemp,$w,$h,imagecolorallocatealpha($imgtemp,$Lcolors["red"],$Lcolors["green"],$Lcolors["blue"],$alpha));
}}
imagepng($imgtemp, realpath(dirname(__FILE__))."\imgtem.png");
//imagecopyresampled($imgtemp, $this->image, 0, 0, 0, 0, $this->width, $this->height, -$this->width, $this->height);
$this->image = $imgtemp;
}
The text was updated successfully, but these errors were encountered:
add this code to: ImageWorkshopLayer.php
too allow you to apply layer mask.
to use $layer_you_wish_to_apply_mask->applyalphamask($mask_layer);
/**
* Apply alpha layer mask.
* can be slower so best for images you don't need to remake for every user.
* @param layer $mask
*
* @author email [email protected]
*
*/
The text was updated successfully, but these errors were encountered: