有没有可能拍下这张图片:

并应用此遮罩:

然后把它变成这样:

使用GD或Imagick?我知道使用形状遮罩图像是可能的,但我不确定如何使用预先创建的字母透明图像进行遮罩。:s
发布于 2010-02-28 21:32:27
使用Imagick和ImageMagick版本>6(我不知道它是否能在旧版本上工作):
// Set image path
$path = '/path/to/your/images/';
// Create new objects from png's
$dude = new Imagick($path . 'dude.png');
$mask = new Imagick($path . 'dudemask.png');
// IMPORTANT! Must activate the opacity channel
// See: http://www.php.net/manual/en/function.imagick-setimagematte.php
$dude->setImageMatte(1);
// Create composite of two images using DSTIN
// See: http://www.imagemagick.org/Usage/compose/#dstin
$dude->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0);
// Write image to a file.
$dude->writeImage($path . 'newimage.png');
// And/or output image directly to browser
header("Content-Type: image/png");
echo $dude;发布于 2009-11-16 22:53:27
我想你是在找imagealphablending。我用它做水印,我相信它能达到你想要的效果。
发布于 2012-06-05 20:16:03
使用(ImageMagick)而不是GD的工作很棒。我看到这个问题的标签是GD!!
以下是此链接中的GD版本:PHP GD Use one image to mask another image, including transparency
https://stackoverflow.com/questions/1741488
复制相似问题